3

I'm a Vim user, so I'm learning Emacs commands for use in the Bash CLI. I know that on my systems I can use Vim-keybindings in Bash but I'd like to learn how to use it effectively in its default configuration.

First order of business: Moving around. Let us assume that I've got the following on the CLI:

$ mv some_long_file_name.txt some_long_file_name_with_slight_change.txt

I'm at the end of the line and I'd like to go back 4 words. In Emacs one would Ctrl+U, 4, Alt+B however on the Bash CLI Ctrl+U erases to the beginning of the line. How to perform the motion, then?

Add auxiliary question, if I may? Assuming that I had successfully completed a move command and I'd like to do it again. How might I do that? So if I contorted my fingers on 5 keypresses to move back 4 words, how might I move back another 4 words?

Note that I am interested in learning how to use the default configuration. I don't want to configure Zsh, Vim keybindings, or .bash_profile.

1 Answer 1

3

Alt-4 Alt-B (like in ksh and zsh, and tcsh where they all most probably copied it from). That assumes the terminal sends the sequence of characters ESC, 4, ESC, b upon those key presses. The same combination works in Emacs too, by the way.

I'm not aware that there's any way to repeat a motion (other than the search ones).

Using Ctrl-R, Ctrl-S (except that for that one, for bash you may need to disable terminal xon) might be a more effective way to move the cursor around.

2

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.