Navigating in Vim's Command Mode

VimText EditorVi

Vim Problem Overview


I am a long time emacs user learning Vim. Emacs lets me navigate in the mini-buffer (where I issue commands like C-x C-s) using the same navigation keyboard shortcuts as in any other buffer. For example, I can navigate forward one character using C-f, even while in the mini-buffer. I could also use the arrow keys, but they are too far away.

Is there any keyboard shortcut to navigate in Vim's command mode (:), without using the arrow keys -- equivalent to emacs C-f, C-b? Thanks.

Vim Solutions


Solution 1 - Vim

Adding to Greg Hewgill's answer, you can use q: to open the command-line window, where you have any Vim editing power at your hand.

Solution 2 - Vim

Some from the Vim help:

CTRL-B or <Home>
        cursor to beginning of command-line
CTRL-E or <End>	
        cursor to end of command-line
CTRL-H				
<BS>		Delete the character in front of the cursor (see |:fixdel| if
        your <BS> key does not do what you want).
<Del>		Delete the character under the cursor (at end of line:
        character before the cursor).
CTRL-W		Delete the |word| before the cursor.  This depends on the
        'iskeyword' option.
CTRL-U		Remove all characters between the cursor position and
        the beginning of the line.  

Solution 3 - Vim

I have these in my .vimrc

cnoremap <C-a> <Home>
cnoremap <C-e> <End>
cnoremap <C-p> <Up>
cnoremap <C-n> <Down>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <M-b> <S-Left>
cnoremap <M-f> <S-Right>

Solution 4 - Vim

With the default key bindings, vim does not offer non-arrow-key navigation of the command line editing. However, see :help cmdline-editing for an example of how to use the :cnoremap command to set up alternate key bindings.

Solution 5 - Vim

I achieved that with <C-p> and <C-n> to navigate previous and next commands respectively.

P.S I'm not making any custom binding like Tassos did.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRohitView Question on Stackoverflow
Solution 1 - VimBoldewynView Answer on Stackoverflow
Solution 2 - VimJeetView Answer on Stackoverflow
Solution 3 - VimTassosView Answer on Stackoverflow
Solution 4 - VimGreg HewgillView Answer on Stackoverflow
Solution 5 - VimFakhri AunurrahimView Answer on Stackoverflow