Vim Tips Wiki
Advertisement

Previous TipNext Tip

Tip: #4 - Any word completion

Created: February 24, 2001 15:48 Complexity: basic Author: Jamo.sp--AT--lorenz.lucs.lu.se Version: 5.7 Karma: 1339/384 Imported from: Tip#4

Either when programming or writing, I tend to have some identifiers or words that I use all the time. By sheer accident, I noticed the 'ctrl-n' command, that will attempt to complete the word under the cursor. Hit it once, and it will try to complete it with the first match in the current file. If there is no match, it will (at least in the case of C code) search through all files included from the current one. Repeated invocations will cycle through all found matches.

Comments

See VimTip11 for more details...

scrott--AT--users.sourceforge.net , February 25, 2001 12:10


that is definitely a life changing tip.

especially when programming and trying to recal variable names and so on. wow. i had no idea.


harry--AT--slaughters.com , October 12, 2002 2:17


Outstanding! I've been following std/boost guidelines for C++ code which specify longish_variable_names_with_lots_of_underbars, since everything is lowercase, you have fewer identifiers to choose from, so your identifiers can get quite long, (i.e. return_temporary_buffer from std). With this feature, it all makes sense. Typos are on the decline. Life altering, indeed.

ajglist--AT--izzy.net , February 2, 2003 1:38


Great tip!

thanks a lot. Yes, I agree, life changing!.

Herman.


hjaramillo--AT--geocenter.com , February 7, 2003 13:10


Damn, this saves me about 1000 keystrokes a day.

Anonymous , June 15, 2003 15:14


I love vim ;-p

Anonymous , July 3, 2003 17:33


Of course this tip is a life changing one :)

Note that you can ask vim for a previous word compeltion with <Ctrl>P

Yo ucan also, for use facilities, map this combo on a not-often-used key such as the '�' one.

But, does anyone know how to make Vim read the Pel modules inculded for compeltion on function names ? Such as it did when editing C code ?

Thanks a lot.

spam--AT--sukria.net , August 11, 2003 4:34


I wish I had known this earlier. Thank for the tip!

Anonymous , January 17, 2004 18:31


I was using good old cut-past!! what a relief...

Thanks for sharing this tip!!!!

Anuya

vaval_anuya--AT--emc.com , October 21, 2004 12:39


Thank you Thank you THANK YOU!!!!!

balaclavabob--AT--hotmail.com , October 26, 2004 3:33


Great..amazing tip

Anonymous , November 2, 2004 11:51


Was searching for a script that list class members, but did not found any that worked. But this tip is probably enoght. Mayby better as you still have to remeber *something* about your code. + It works in school too. :-)

Anonymous , November 21, 2004 11:53


Even better is this script, that allows word completion by hitting the TAB key, the same you'd do on bash: http://www.vim.org/scripts/script.php?script_id=182 i.e. [/scripts/script.php?script_id=182 vimscript #182]

Anonymous , March 5, 2005 14:24


Yehaaa. Wow, i missed this feature :-) But it appears to me that it does not complete with the first match in the file, but with the first occurence alphabetically.

Anonymous , April 25, 2005 5:21


Quite useful. Relieves me from the pain of shifting between vim windows

Anonymous , September 14, 2006 5:06


I've been using this for quite some time till I bumped across VIM 7. There is a ghastly PINK popup which screws my mind each time I see it. Nor does it work like VIM 6 used to. I really regret the upgrade. Is there any way to make it go away without me having to switch back to 6???

nikhilgupte--AT--gmail.com , September 18, 2006 8:24


look at the option 'completeopt' which controls this - you can unset it to disable the menu

Anonymous , September 27, 2006 21:04


Advertisement