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
    forums
Old 02-17-2003, 12:40 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,471
sde is on a distinguished road
VI Editor Tips

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.
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 09:18 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting