User:Kpsingh79/sandbox

KP sandbox

http://www.thegeekstuff.com/2009/01/vi-and-vim-editor-5-awesome-examples-for-automatic-word-completion-using-ctrl-x-magic/

1. Word / Pattern Completion in Vi / Vim Using Ctrl-x Ctrl-n You can use one of the following Vim shortcut keys to choose the existing words on the file.

CTRL-x CTRL-n : Word completion – forward

CTRL-x CTRL-p : Word completion – backward

2. Line Completion in Vim using Ctrl-x Ctrl-l If you want to insert an existing line, type the first few words/characters of the line, and then press the Vim shortcut keys “Ctrl+x Ctrl+l”, which will display all the lines matching that patten. Note: The second control character is a lowercase L.

3. File Name Completion Using Ctrl-x Ctrl-f Insert the name of the file that resides anywhere on the Linux system using the short cut key “Ctrl+x Ctrl+f”.

5. Dictionary Word Completion Using Ctrl-x Ctrl-k Enable the dictionary in Vim by adding the following line to ~/.vimrc. $ cat ~/.vimrc set dictionary+=/usr/share/dict/words This is a great feature when you stumble for the correct spelling for a word that you are typing. After typing the first few characters, Press the Vim short cut key Ctrl-x Ctrl-k to display the matching dictionary words.

Final Note: Verify whether autocmd is enabled in Vi / Vim – Execute :version from vi / vim. If autocommand feature is enabled, it will display +autocmd. Insert Mode Completion help – Execute :help ins-completion from vi / vim, to get quick help on insert mode completion features.

vim can edit multiple files in a multi-split-screen environment. Type :help usr_08.txt for details. To split the screen display between different files, type at the vi command prompt: :split another-file :vsplit another-file

Or at a shell prompt: $ vi -o file1.txt file2.txt  # Horizontal split $ vi -O file1.txt file2.txt  # Vertical split

will provide multiwindow vi. $ vimdiff file.txt~ file.txt        # check recent changes of file.txt $ vimdiff file.en.sgml file.fr.sgml # check changes of translation $ gvimdiff file.txt~ file.txt       # in X

will provide a nice view of differences between an original and a backup file. In SGML it matches tags, so comparing translations in this mode works very well. Special cursor movements with Ctrl-W commands: Ctrl-W +     increase the size of a window Ctrl-W -     decrease the size of a window Ctrl-W h     move to the window left Ctrl-W j     move to the window below Ctrl-W k     move to the window above Ctrl-W l     move to the window right ...

Use the following to control screen scrolling: :set scrollbind :set noscrollbind