0

If I am editing a command, for example:

:set paste

And my cursor is between the p and a:

:set pa|ste

I can go to the end of the command text by doing ctrl-e. However it doesn't seem like ctrl-a works to go to the start of the text. Is there a shortcut that I can use to go to the start of a command I'm typing? For example, I'd like to be able to enter a key(s) to be able to get to:

:|set paste

How can that be done?

1

You can set command line mappings with cmap.

In your case:

cnoremap <c-a> <Home>
4

By default, Vim command line uses Ctrl-B to go to the beginning of the line. Execute :h cmdline-editing to see more key bindings.

Most command line tools follow the Emacs key bindings, and you can write your own mappings if you want. See :help cnoremap for details. There are also plugins, like rsi that do it for you

1

Ctrl-F is very handy as it puts the current command line in an editable window, that also shows history. You can use all the Vim commands here to edit the current command, including traversing earlier commands in history.

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.