4

tldr

Moving in ex command line is slow because common readline motions (like in bash) are not supported. Are there any improvements for this?


I often find myself with an ex command in the command line and the need to e.g. edit something at the very beginning. For instance, I may have entered ex mode and pressed to repeat the last ex command. I then have

:e src/Sensors/Camera/SimulatedCameraSensor.cpp|

in the command line, with | being the cursor. In readline-enabled programms, I could use Ctrl-A or Alt- ← to quickly move to the beginning of the line, but in vim I seem to have to press the left arrow and move over individual characters.

Is there any configuration or are there any shortcuts which will speed up cursor motions?

0

2 Answers 2

5

I have found two workarounds:

  1. This plugin adds some readline motions to command mode
  2. As outlined here, one can press Ctrl-f in command mode to make the current command editable like in normal mode. This is incompatible with the option 1.
1
2

I’ll add my most common alternatives:

  • Use the default :-editing bindings (:help commandline-editing or something similar, if anyone has the reference offhand feel free to edit). <C-b> is beginning, <C-e> is end, and there are others
  • Use the wonderful <C-f> if you started a :, ?, or / and want to edit like it’s a normal vim buffer.
  • Use q:, q?, or q/ if you know you need this when you start.

I have <leader>; mapped to q: so a vim-edited command-line is very quick access. (I prefer not to switch ; and : in my everyday editing, but I’m considering it.)

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