Vi & VimVi is an editor which can be found on almost any Unix or Unix-like machine. So almost any computer running an operating system such as UNIX, FreeBSD, Linux or similar will have the vi editor installed. Unfortunately the most people experience vi as the most user unfriendly editor there is. They definately haven't seen Emacs or sed, but that's another issue. This page will provide some basic things you need to know about vi in order to learn to use it. For almost any Unix program the RTFM-rule (Read The F*cking Manual) applies, so vi also can be learned in that way. Tutorials are available and many systems will let you type in "man vi" to access the vi man pages. But it may be handy to know some basic things about vi before tarting around with it. Since many persons didn't like the way vi had to be used an effort was made to make the editor more user friendly. The editor was rewritten and improved in many places. This new version of vi was more user friendly and therefor it was called vim which is an ancronym for Vi iMproved. Obviously many versions of this editor are around. Some really nice versions of vim also have syntax highlighting for many purposes like programming Java, C++ or JavaScript, or writing HTML, XHTML, XML, CSS, etc. Basic Vi/Vim CommandsNote that all commands are case sensitive. So the i command is not the same as the I command!
Vi: Search and ReplaceChange to normal mode with <ESC>. Search (Wraped around at end of file):Search STRING forward : / STRING. Search STRING backward: ? STRING. Repeat search: n Repeat search in opposite direction: N (SHIFT-n)Replace: Same as with sed, Replace OLD with NEW: First occurrence on current line: :s/OLD/NEW Globally (all) on current line: :s/OLD/NEW/g Between two lines #,#: :#,#s/OLD/NEW/g Every occurrence in file: :%s/OLD/NEW/g LinksContact the author: Send an electronic mail to: pajtroon@dds.nl. This page: Copyright © 2002 Peter A. J. Troon Note: This page is part of the Peter Troon Site. |