Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim auto-completion on substitutions and searches in the command line

Tags:

vim

vim-plugin

Is it possible to use Ctrl+n style auto-completion when doing searches and substitution commands in vim?

What I mean is: say I have a variable named myNumber in my current file. If I enter insert mode and type myNu and then hit Ctrl+n, it will autocomplete the word to myNumber (assuming there are no other words that start with those letters).

Is there any way to get this same functionality on the command line? Is there a setting or plugin that will allow me to type /myNu and then hit a key to complete my text search to /myNumber ? Or, more realistically: let me type :s/myN and complete that to :s/myNumber so I can more quickly type out substitution commands?

like image 301
3rf Avatar asked Nov 01 '13 16:11

3rf


3 Answers

While in command mode, press Ctrl+f — you will enter command line window. There you can edit your command like in vim. Auto-completion should work too.

like image 107
Kent Avatar answered Nov 10 '22 13:11

Kent


Looks like the plugin http://www.vim.org/scripts/script.php?script_id=2222 does more or less exactly what I wanted. Upvoting Kent though, because that's really nifty.

like image 40
3rf Avatar answered Nov 10 '22 13:11

3rf


This plugin also enables auto-completion in command line.

https://github.com/vim-scripts/sherlock.vim

like image 1
Naga Kiran Avatar answered Nov 10 '22 15:11

Naga Kiran