outsource from india chennai india programmers freelance php coder freelance outsource scripts programming complicated perl patterns php module installation
outsource from india perl installation and configuration php installation linux system administration US$15,US$19,US$11,US$10 cheap programmer
india outsource outsource india chennai india programmers php perl mysql freelance freelance programmer
SHOWCASE of php and perl scripts CONTACT US for php custom perl scripts
HOME
 

4. Auto-Completing Words

Consider the following code

Figure 9. Auto-completion example

The function A_Very_Long_Function_Name() can be quite exasperating to type over and over again. While still in insert-mode, one can auto-complete a word by either searching forwards or backwards. In function, Another_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 using the following mechanism.

	 #include "f CTRL-X CTRL-F"
      

That's CTRL-X CTRL-F. I know... I know... Its sounds like emacs ;-). There are other things you can do in the CTRL-X mode. One of them is dictionary completion. Dictionary completion allows one to specify a file containing a list of words which are used for completion. By default the dictionary option is not set. This option is set by the command :set dictionary=file. Typically one can put in C keywords, typedefs, #defines in the dictionary file. C++ and Java programmers may be interested in adding class names as well.

The format of a dictionary file is simple. Just put a word you want in line by itself. So a C dictionary file would look something like this.

Figure 10. A sample dictionary file

To use the dictionary completion, one needs to hit CTRL-X CTRL-K. The completion is similar to the CTRL-P and CTRL-N keystrokes. So... to type "typedef" all one needs to do is t CTRL-X CTRL-K and poof... the name completed.


Linux HOWTO full list
   This document, LDP HOWTO-INDEX, is copyrighted (c) 1995 - 2002 by Tim Bynum, Guylhem Aznar, Joshua Drake and Greg Ferguson. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is available at http://www.gnu.org/copyleft/fdl.html. If you have questions, please contact the LDP.
Web Design Copyright © 1999-2003. Chrisranjana Software Solutions Pvt Ltd. syndicate rss feed