If you have a word already typed in your file you are editing in vim, then you can use "autocomplete" feature of vim editor for the future typings of the same word.
Type first few of the words initial characters(minimum 1), and keep hitting "ctrl-p" till you get the word you are interested.
In the above snap, I typed f_ and then pressed "ctrl-p", f_Compare,f_Exists,f_round are matching "f_". As I am interested in f_Compare, I had to hit "ctrl-p" twice after this to get the same(f_Compare is highlighted), then I pressed enter. Done!!
13 comments:
Dont you need to put some thing in your .vimrc before this works. I cant get it to work on my ubuntu 8.10.
@Babar,I dont feel we need any setting to be done on .vimrc.
Thank you for your reply. Any idea then why it does not work on my side? What distro are you on?
I am on Ubuntu 7.10 (I saw it working in Debian 3.0 as well). You can just see if your vim is the latest one, or get apt-get of latest vim. Does vimdiff works on your ubuntu ?
Weird. I am on 8.10 which should have the latest version of vim. I also upgrade my system regularly. vimdiff gives me "This Vim was not compiled with the diff feature."
@babar, please do a
$ sudo apt-get install vim
and try now. I feel latest vim should solve your vimdiff,color syntx in vim as well as autocomplete. :-)
Perfect! Thanks yar, appreciate it.
@Babar, always welcome, ty :-)
Increment and decrement feature of vim:
One more interesting vim tip to all of my friends. if any number is present in the vim editor, move the cursor beneath to that number, and
use ctrl+ a for increase that num
ctrl+ x for decrement that num
For hexadecima increments and decrements use 0x before that number and follow the above steps
@Adithya,thats really a nice one. Thanks for the tip. I am thinking of making it a separate post. Thanks
Ya you are right. Make my tip as a separate post. cheers!!
One more great vim tip to share with you guys
When you are searching for a particular pattern in a file using vim editor, that pattern gets highlighted. This is some times annoying for us when you open another file and vim will try to highlight if the same pattern is available. To unhighlight the highlighted text, use
:noh
in the vim command mode. If you wanna revert back just press "n"
done!!
^p is the previous line in that menu, ^n is the next one.
You may also consider adding "set completeopt+=longest" to your vimrc. It will be more like the bash's autocomplete feature. Just try it and you'll see whether you like it.
Post a Comment