Monday, July 9, 2012

Few vim techniques

There are many commands to work with vim editor but here are few which will be more useful in realtime.

vim +/keyword file name

will place the cursor to the exact key workd line, you can also use the line number like below

vim +linenumber filename

to move the cursor from the reverse you can use

vim +?keyword file name

you can also enter the vim editor and press ? to search the keyword from reverse. To check from the correct order you can use /key word.

To view the line numbers you can press ESC:se nu

Some of the method to copy the lines in the file.

yy

to copy 10 lines you can use yy10

to paste you can use P

you can also use the visual mode and select the lines you require to copy.

ctrl+z and selecting the lines and use right click copy or yy.

To select all the lines from the cursor point you can use yG

To make your files more secured, you can set password for your files.

open vim editor type the content, ESC:X
type password.
:wq

There after when ever you need to access the file it will prompt you to enter the password. If incorrect password is set the data will be displayed in the encrypted format.

use vimdiff command to find the difference between two files .
use ctrl +ww to change the switch the cursor to the other file and if you need to copy the line to the next window press ctrl dp

No comments: