Hits: 6,205
Home >> Software >> Vim Editor

Vim Intro

Vim or Vi iMproved is one of the most flexible, powerful, and fastest editors for multi-platform use. Of course every user likes something different, Vim [www.vim.org] has it's own wide user base. Vim is built of the old UNIX editor Vi that you will find on almost every UNIX system. When the system goes down and all you have is a boot floppy, you won't find big editors like EMACS on there, only Vi. So it's a good skill to know how to do basic editing with Vi/Vim.

Basic Editing

Vim is usually packaged with a tutorial that can be accessed using vimtutor. This is a good place to start the process. In addition to this tutorial, you can also find good information on http://vim.sourceforge.net site.

Search/Replace

To search in Vim first make sure you are in visual mode. Press ESC and then press / followed by your search phrase. To do a case insensitive search, first go into command mode and set case insensitive mode. :set ic

Replacing text can be done one of many ways. To replace all text in the file use :%s/old/new/g. If you only want to replace text on a block of text you can use :10,20s/old/new/g to replace all text between lines 10 to 20. In addition, the g at the end of the line tells Vim to replace all occurrences in the line, not just the first one.

Cut/Paste/Buffers

There are two basic methods to cut and paste in Vim. You can use the global buffer, for example, by pressing YY to "Yank" the current line into the global buffer. Then you can paste below the current line using p. You could, of course, add a number of lines to yank into the buffer. 30Y will Yank 30 lines into the buffer.

Using named buffers or registers allows you to have more then one in memory at a time. To yank into the buffer A, we would use "a10Y to grab 10 lines into buffer A. Then to paste them, a simple "ap would paste them into the document. Buffers are not case sensitive so A is the same as 'a'.

Advanced Vim

More to come soon, such as templates etc. For now check out http://vim.sourceforge.net site.