简体   繁体   中英

Moving around the vim command line

I've been a vim user for a while now and I know how to move around the files, but is there anyway to do so on the editor command line itself (is there a name for that?).

eg I typed :vimgerp /sometext/ files/*.js and I realized I spelled :vimgrep incorrectly and I want to just jump to the beginning of that line and fix it. Any other sort of small tips here (jump between words -- neither w,e nor alt+left/right seem to work) also appreciated.

http://vimdoc.sourceforge.net/htmldoc/usr_20.html

<Left>          one character left
<Right>         one character right
<S-Left> or <C-Left>    one word left
<S-Right> or <C-Right>  one word right
CTRL-B or <Home>    to begin of command line
CTRL-E or <End>     to end of command line

The easiest method would be to use CTRL - F . This opens your command in the command-line window where you can edit your misspelled command like any other plain text.

from vimhelp

OPEN c_CTRL-F q: q/ q?

There are two ways to open the command-line window:

  1. From Command-line mode, use the key specified with the 'cedit' option. The default is CTRL-F when 'compatible' is not set.

  2. From Normal mode, use the "q:", "q/" or "q?" command. This starts editing an Ex command-line ("q:") or search string ("q/" or
    "q?"). Note that this is not possible while recording is in progress (the "q" stops recording then).

It's not the fastest and therefore probably only worth it for long commands, but you could just hit enter on the incorrect command as is, u ndo any incorrect changes if necessary, then open up your command history with q: , where you can edit it as you like. Enter then runs the command if you have your cursor over it in the command history buffer.

Also, shift+arrow left/right jumps between words in command mode, and you can use home/end to go to the beginning and end.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM