
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Gotta Learn Vi . . . . . . (was Re: [tlug] [Newbie] Becoming'root' in Kubuntu: Use sudo)
Um WARNING -- this may be more than you want to know. The
25 or so basic vi commands are toward the bottom. They
should work on any vi anywhere. I didn't intend to write
this much.
Steve S.
> On Sat, Aug 25, 2007 at 02:12:33PM +0900,
burlingk@example.com wrote:
>>
>> What are the differences between vim and vi.
>> I've only ever used vim. I know it is basically
>> a drop in replacement in a lot of ways, but are
>> there any noteable differences between the two? :)
Actually the list of differences is huge and personally I
don't use most of them. Like emacs, the list of things that
vim can do goes on and on and on. Odds are you will never
see the original vi though so don't worry about it. For as
long as I can remember on Linux the two have been the same.
On my laptop, both point to /usr/bin/vim.perl -- what ever
that is. The Solaris 2.7 box I worked on until about 4
months ago still had the original vi, and that's what I had
to work with. Think of vi as a tiny subset of vim.
The original vi was written by Bill Joy -- way back when. It
did not do multiple windows -- or actually at one point, it
did do multiple windows but the code got lost.
The original vi only had the few commands below It worked
over a 300 baud modem. There were no arrow keys, no
home/end/pageup/pagedown/insert/delete/function keys. The
processor might well have been a 68000 on the newer
machines. I've forgotten what was on the DEC machines.
The basic difference between emacs and vi/vim is that vi is
a 'mode' editor -- you were in insert mode which changed
characters or not. To exit insert mode you pressed the
escape key. People seem to either love this or hate it.
These commands put you into insert mode:
i,I put you into insert mode. i inserts where the cursor is,
I was in front of the first non-white space character on
the line.
a,A put you in append mode. a appended behind the cursor, A
at the end of the line.
o,O 'open' a line afer/before the cursor
cursor movement -- only works when not in insert mode
j,k moved cursor down,up
h,l moved cursor left, right
space key also moved character right.
e,E end of word, end of WORD
0,$ begin/end of line
^F,^B page forward, page back
Search:
/<regex> search forward for regex
?<regex> search previous for regex. Also use as easy way to
search for things with '/' in them
n,N next/previous match
x,X delete under the cursor/in front of cursor.
r,R replace character/rest of word
D delete rest of line
cw change word
s/<regex>/<change>/[gc] substitute <change> for <regex>
g -- change all occurances on line
c -- confirm -- ask me first
maybe a few others...
:0 first line of file
:$ last line of file
:N line N of file where N is a number
:%s/<regex>/<change>/[gc] -- like substitute above but on
whole file
:q quit file
:w write changes to file
:e <file> edit file
:n next file
:w! write changes over existing file
:q! quit without writing changes and don't warn me that I'm
not writing changes
:! <command> execute command
% -- name of current file
# -- name of previous file
the '.' command for repeating a command.
u undo previous command
U undo changes to current line.
There are also ways for marking location in file, named
buffers for 'yanking' characters, ways to move lines, ways
to work on multiple files, ways to repeat a command multiple
times, and so on.
Like emacs, vim goes onandonandonandon with what it can do.
There are people who use emacs and people who use vim as
their shell/terminal. Both are highly extensible and I
think the line between the two (I don't know if Steve will
agree :) is becoming blurred, but the 25 (aprox) commands
above should work on any vi anywhere.
Steve S.
Home |
Main Index |
Thread Index