简体   繁体   中英

Vim - how to auto complete buffer contents in command-line mode

Use case: I have a buffer

variable1
variable2
variable3

i want to replace variable1 with variable3 using

:%s/vari<TAB>/vari<TAB><TAB><TAB>

can this be done somehow? I don't want to have to type out or manually copy words

I vaguely remembered this old plugin from way back and, well… it still seems to do the job:

编译

You can use the command-line window (see :help cmdline-window ) to use regular Insert mode to write an Ex command-line such as :s .

You can either use q: from Normal mode to access the command-line window, or use Control + F from the Ex command-line (after typing : and even starting to write a command such as :%s/vari ...)

Once in the command-line window, you can use i (or a , A , etc.) to enter Insert mode, and then you can use the usual completion keystrokes such as Control + N or Control + P to complete from contents of other visible buffers.

Once the :%s command is complete, you can simply press Return to have the command from the command-line window executed as a regular Ex command.

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