Most of you programming freaks, like the Auto Complete idea of an IDE (using Ctrl+Space) to complete the word. And all the GUI IDE lovers think Vi is just another “Notepad”.
Beware, VIM is noway behind the IDEs, It too supports your Auto-Complete.
Ctrl+P (match previous tokens) or Ctrl+N (match tokens ahead/next) is an alternative to Ctrl+Space
Consider you have following file contents.
RewriteCond %{REQUEST_URI} /somefilepath1/.*
RewriteCond %{REQUEST_URI} /somefilepath2/.*
Now if you want to add another RewriteCond, and you have reached till “Rewri”
All you have to do is press Ctrl+P, Vim will automatically add “teCond” to the string “Rewri”
June 27, 2006 at 10:02 pm |
your comment does not work i tryied it alretty
June 29, 2006 at 1:17 pm |
it does work, I use it frequently.
February 19, 2007 at 11:08 pm |
It does work.
jake you are WRONG
June 2, 2007 at 12:16 am |
Sweet, I was not aware of this trick. It does work!
August 31, 2007 at 8:55 am |
Perhaps you could try a somewhat more civil answer instead of yelling at the guy who can’t spell: This only works in Vim 7. Jake is probably using an older Vim install.
September 13, 2007 at 4:44 pm |
It´s more ‘auto-remember’ than ‘auto-complete’ since it only seems to recall functions previously used in the same file (I use vim 6.3.82)
But thanks for the tip.
September 14, 2007 at 10:05 am |
In Vim 7, u can ‘auto-complete’, check
http://ruturajv.wordpress.com/2006/12/21/vim-7-autocomplete/
October 10, 2007 at 12:36 pm |
It works fine for me!
February 13, 2008 at 5:04 pm |
I think CTRL+B is not correct in Vim7.1 ist CTRL+N
February 14, 2008 at 12:26 pm |
thanks for ur comment Juergen, you are right, I’ve updated my post as well.
April 5, 2008 at 1:30 pm |
there is more to it.
press control plus “x” and release for a sec, then press lowwercase “L”
and it will autocomple the entire line
(Ctrl-key) + (x) & (l)
also if you press control +”e” the carachters in the line above will be
cloned on your current line.
control + “y” will do the same thing for the line below.
and if its kept press it’ll run coping the line until released
am telling you vim is some serious geek shit!
today I fond out you cand export you current buffer with line numbers and all
to html exactly as it looks in vim.
try the following command
:TOhtml
March 11, 2009 at 9:53 pm |
Thanks for the menu color setting, that pink has been driving me crazy! I use the autocomplpop.vim to automatically pop up the omni complete options, seems to work well.
Thanks,
Steve
March 12, 2009 at 9:55 am |
Hey Steve,
Thanks a ton, the http://www.vim.org/scripts/script.php?script_id=1879 script is awesome!!!
March 27, 2009 at 7:34 pm |
I love this auto complete feature. But in newer versions of Linux distros some option has been turned on because of which a list of matches pops up every time I hit ctrl-p. It is very distracting. How can I disable it ? I want the auto complete feature without the popup.
Thanks,
-Rahul
May 28, 2009 at 6:12 am |
“it only seems to recall functions previously used in the same file”
Not true, if you open all your files within vim (very easy from command line) and they are always loaded when ever there is an error or warning while compiling with Make.
e.g.
$ vim source/*{cpp,h}
Also, if you use Ctags, this will keep a reference to all relevant tokens.
$ ctags -R .
Done…
May 28, 2009 at 6:16 am |
Rahul, you can map Autocomplete to a different key combination.
BTW, did anyone see this?:
http://vim.wikia.com/wiki/Ctrl-p_-_autocomplete
File completion:
Line completion:
Omni completion:
There much more to this than just token completion…. even line completion … and if using ctags,… it give you a description of the function/etc up top in a preview window.
CTRL-z to close preview
.. that’s the next question, I am sure.
June 2, 2009 at 3:06 am |
Cool!
Works for me