> I simply said "I should not have to read a manpage to use an editor", 
> then it snowballed from there, starting with Joey Kelly's post giving me 
> some features of VI that I dont' need.  Has nothing to do with whether 


I have to agree, vi is a tough tool to learn. If you don't have a
specific need/reason to use some of it's advanced features then it's
really  hard to remember them to be able to use the next time you
need it. That's why I have two cheat sheets taped to my wall by my
desk. I think they've been there about 5 years, and I barely look
at them anymore! Here's some of the day to day stuff I use:

yy copy a line
dd cuts a line
p paste your copy/cut
P paste your copy/cut on the line above the one you're on
dw delete a word
cw delete a word then put yourself into insert mode
x delete a character
r replace a character with the next button you type
i puts you in insert mode
a puts you in insert mode
ESC takes you out of insert mode and puts you back in command mode
h left one character at a time
j down one line at a time
k up one line at a time
l right one character at a time
w move forward one word at a time
b move back one word at a time
Ctrl-f page down
Ctrl-b page up
/ to search for text, type your search word after the /
n find next occurance of your search
^ or 0 move cursor to begging of the line
$ move cursor to end of the line
[[ move to top of file
]] move to bottom of file
o open a blank line below current line
O open a blank line above current line
:q quit the file
:q! quit the file without saving
:w write the file
:wq write the file and quit


Now, the next couple things are the reasons I wanted to
and currently do use vi. It's the search/replace functions.

:s/oldword/replacedword/g

that will replace every instance of oldword with repacedword
on one line. if you add a % it will do it in the whole file:

:%s/oldword/replacedword/g

also, you can do this, add some text to the begining of every line
in a file:

:%s/^/addtext/g

or add text to the end of every line in a file:

:%s/$/addtext/g

You can read in a file:
:r filename


The search/replace stuff is what I use most often, while creating
scripts or editing files.

Does anyone else have some cool feature of vi that they use that
they would like to add to the cool feature list??


BB

Reply via email to