9

The standard CTRL-E works to go to the end of the line but CTRL-A doesn't seem to work to go to the beginnig.

It would obviously be useful to quickly go to the beginning of line for example if one wanted to replace w /path/to/file in with w! /path/to/file.

Is there a key to go to the beginning of the line in command mode and if so how does one map it to CTRL-A?

Yanevski
  • 193
  • 3

1 Answers1

12

You can use <C-b> to go to the beginning of the line; from :help c_CTRL-B:

CTRL-B or <Home>                                c_CTRL-B c_<Home> c_Home
                cursor to beginning of command-line

If you want, you can use this to map it to <C-a>:

:cnoremap <C-a> <C-b>

Related: How can I use Readline shortcuts in the vim command line?

Martin Tournoij
  • 62,054
  • 25
  • 192
  • 271