Tech and Academic things for Chianshin

Saturday, January 13, 2007

C editing with VIM HOWTO

C editing with VIM HOWTO: "Function() one can type A_Very... and hit CTRL-P. The first matching word will be displayed first. In this case it would be A_Very_Long_Variable_Name. To complete it correctly, one can hit CTRL-P again and the search continues upwards to the next matching word, which is A_Very_Long_Function_Name. As soon as the correct word is matched you can continue typing. VIM remains in insert-mode during the entire process.

Similar to CTRL-P is the keystroke CTRL-N. This searches forwards instead of backwards. Both the keystrokes continue to search until they hit the top or bottom.

Both CTRL-P and CTRL-N are part of a mode known as CTRL-X mode. CTRL-X mode is a sub-mode of the insert mode. So you can enter this mode when you are in the insert-mode. To leave CTRL-X mode you can hit any keystroke other than CTRL-X, CTRL-P and CTRL-N. Once you leave CTRL-X mode you return to insert-mode.

CTRL-X mode allows you do auto-completion in a variety of ways. One can even autocomplete filenames. This is particularly useful when you have to include header files. Using CTRL-X mode you can include a file foo.h usi"

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home