Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    linux
  » VI Editor Tips
      by sde
 Page 1 of 1 
   

(Login to remove green text ads)
If you use *nix, then you will have to learn to use VI sooner or later... and the sooner the better.

Use the following command to start editing a file:
Code:
$ vi filename.txt
Now you have the text file open and ready to command. Below is a reference of VI commands.
Code:
Move Characters j down k up l right h left ------------------------- Text w,W Move forward by word b,B Move backward by word e,E End of word (,) Beginning of next, previous sentence },{ Beginning of next, previous paragraph ]], [[ Beginning of next, previous section -------------------------- Lines <Enter> First nonblank character of next line 0,$ First, last position of current line ^ First nonblank character of current line +,- First nonblank character of next, previous line H Top line of screen M Middle line of screen L Last line of screen ---------------------------- Searches /pattern Search forward for pattern ?pattern Search backward for pattern n,N Repeat last search in same, opposite direction /,? Repeat previous search forward, backward fx Search forward for character x in current line Fx Search backward for character x in current line ----------------------------- Line Number CTRL-G Display current line number nG Move to line number n G Move to last line in file :n Move to line n in file ------------------------------ Editing Commands ------------------------------ Insert i,a Insert text before, after cursor I,A Insert text before beginning, after end of line o,O Open new line for text below, above cursor ------------------------------ Change r Replace character cw Change word cc Change current line cmotion Change text between the cursor and the target of motion C Change to end of line R Type over characters s Substitude: delete character and isnert new text S Substitute: delete current line and insert new text -------------------------------- Delete, move x Delete character under cursor X Delete character before cursor dw Delete word dd Delete current line D Delete to end of line p,P Put deleted text after, before cursor ----------------------------------- Exit Commands ----------------------------------- ZZ Write and quit file :x Write and quit file :wq Write and quit file :w Write file :w! Write file, overriding protection :q Quit file :q Quit file, overriding protection Q Quit vi and invoke ex
There are many other commands out there, but these are some key commands to edit in VI comfortably.




 
 Page 1 of 1 
   

Rate This Article
1 2 3 4 5 6 7 8 9 10





Copyright © 2000-2006, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting
Open Circle