About Me

My photo

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/E/B d-- s:++>: a-- C++(++++) UL++ P! L++ E--- W+++ N+++ w PS+ PE- !tv
b+++ G++ e++ h
------END GEEK CODE BLOCK------

Monday, June 20, 2005

ctags and some vim stuff

If you are editing a C program using vim, then create a tag file using ctags

:!ctags . [ . for the current file ]
OR
:!ctags * [ * for all the .c and .h files, if you are in a src directory]

Now, the next time you stumble across a function name,variable name and you want to know its declaration, then just do a CNRL + ]. Thats it! Quite useful.

Another feature of Vim is Auto-completion. for example
#include<expat.h> has number of XML related declarations typing the first few characters of variable and then doing CNTL+N
should provide you list for the auto-completion. Interesting, huh?

XML_ERROR_JUNK_AFTER_DOC_ELEMENT
XML_SetProcessingInstructionHandler
XML_SetUnparsedEntityDeclHandler
XML_SetExternalEntityRefHandlerArg

I could have never typed the above properly (without losing my sense, CNTL+N helped me)


...creating a tags file is the first thing I do when browsing a program
- Bram Moolenar in Vim: Seven habits of effective text editing.

2 comments:

Kannappan said...

AutoCompletion is one good feature of gmail as well. (obviously)

And the slightly similar find as you type firefox browser.

phoe6 said...

Yeah, the first time I discovered this Auto-Completion feature was in MS Outlook. An ardent fan of this feature since then.