1

Crash shell allows to specify the command line editing mode to vi or emacs.

What will be the difference in these input methods?

I am not asking about the internal features.

3

You can find out which is set via set -o.

Setting these effectively changes some of the nature of how commmand line history and command editing works. They are named after the respective editors because they present the user with familiar command behaviour. When in vi mode you default to insert, so commands can be edited as per usual. However if you press <escape> you will enter command mode. Here you can then use usual vi commands:

  • b will move you back a word
  • w will move you forward a word
  • 0 will take you the beginning of the command line
  • $ will take you to the end of the command line
  • k will go to the previous command
  • j will go to the next command
  • ? will allow you to search previous commands
  • d0 will delete from the cursor to the beginning of the command

To return to editing (insert mode) use one of I insert a beginning for first word on line, i under cursor, a after cursor or A at the end of the line.

For emacs mode you can use commands at the same time you edit (there is no insert mode) for emacs. Similar commands to vi mode are:

  • <meta-b> will move you back a word
  • <meta-f> will move you forward a word
  • <ctrl-a> will take you to the beginning of the command line
  • <ctrl-e> will take you to the end of the command line
  • <ctrl-p> will go to the previous command
  • <ctrl-n> will go to the next command
  • <ctrl-r> will search previous commands
  • <ctrl-u> will delete from the cursor to the beginning of the command

To insert raw control sequences (rather than have an emacs command be processed) proceed the sequence with <ctrl-v>. As to which you use, is left as an exercise the the reader :) Also both modes offer a lot more commands than I have listed (refer to manuals of each of the editors for more details!)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.