?? vi and vim editor advanced features.mht
字號:
From: <Saved by Microsoft Internet Explorer 5>
Subject: VI and VIM editor: advanced features
Date: Wed, 4 Apr 2007 10:58:48 +0800
MIME-Version: 1.0
Content-Type: multipart/related;
type="text/html";
boundary="----=_NextPart_000_0101_01C776A8.38FDD110"
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3028
This is a multi-part message in MIME format.
------=_NextPart_000_0101_01C776A8.38FDD110
Content-Type: text/html;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable
Content-Location: http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html
=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>VI and VIM editor: advanced features</TITLE>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3DUTF-8"><LINK=20
href=3D"http://www.yolinux.com/TUTORIALS/yolinux.css" type=3Dtext/css=20
rel=3DSTYLESHEET>
<META content=3D"vi,vim,advanced,linux,unix,vi editor,vi guide,vi help"=20
name=3DKEYWORDS>
<META=20
content=3D"VI Linux editor tutorial of advanced features and tricks. The =
YoLinux portal covers topics from desktop to servers and from developers =
to users"=20
name=3DDESCRIPTION>
<META content=3D"Greg Ippolito" name=3Dauthor>
<META content=3D"MSHTML 6.00.2900.3059" name=3DGENERATOR></HEAD>
<BODY text=3D#000000 bgColor=3D#cccccc>
<HR SIZE=3D5>
<P>
<TABLE width=3D"100%" callpadding=3D"4">
<TBODY>
<TR>
<TD vAlign=3Dtop><A href=3D"http://www.yolinux.com/"><IMG=20
alt=3D"Yolinux.com Tutorial"=20
=
src=3D"http://www.yolinux.com/TUTORIALS/images/YoLinux_Tutorial_logo.png"=
=20
border=3Dnone></A> </TD>
<TD vAlign=3Dtop>
<TABLE>
<TBODY>
<TR>
<TD width=3D"70%">
<H1>Linux vi and vim editor: advanced features =
</H1></TD></TR>
<TR>
<TD vAlign=3Dtop align=3Dright><!-- BEGIN RICH-MEDIA BURST! =
CODE -->
<SCRIPT language=3DJavaScript>=0A=
rnum=3DMath.round(Math.random() * 100000);=0A=
=0A=
document.write('<scr'+'ipt =
src=3D"http://www.burstnet.com/cgi-bin/ads/ad9427a.cgi/v=3D2.0S/sz=3D468x=
60A|728x90A/'+rnum+'/NI/RETURN-CODE/JS/"></scr'+'ipt>');=0A=
=0A=
</SCRIPT>
<NOSCRIPT><A=20
=
href=3D"http://www.burstnet.com/ads/ad9427a-map.cgi/ns/v=3D2.0S/sz=3D468x=
60A|728x90A/"=20
target=3D_top><IMG alt=3D"Click Here"=20
=
src=3D"http://www.burstnet.com/cgi-bin/ads/ad9427a.cgi/ns/v=3D2.0S/sz=3D4=
68x60A|728x90A/"=20
border=3D0></A>=20
</NOSCRIPT><!-- END BURST CODE =
--></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
<P>
<HR SIZE=3D5>
<P>This "<B>vi</B>" tutorial is intended for those who wish to master =
and=20
advance their skills beyond the basic features of the basic editor. It =
covers=20
buffers, "<B>vi</B>" command line instructions, interfacing with UNIX =
commands,=20
and ctags. The <B>vim</B> editor is an enhanced version of <B>vi</B>. =
The=20
improvements are clearly noticed in the handling of tags.=20
<P>The advantage of learning <B>vi</B> and learning it well is that one =
will=20
find <B>vi</B> on all Unix based systems and it does not consume an =
inordinate=20
amount of system resources. Vi works great over slow network ppp modem=20
connections and on systems of limited resources. One can completely =
utilize vi=20
without departing a single finger from the keyboard. (No hand to mouse =
and=20
return to keyboard latency)=20
<P>NOTE: Microsoft PC Notepad users who do not wish to use "<B>vi</B>" =
should=20
use "<TT>gedit</TT>" (GNOME edit) or "<TT>gnp</TT>" (GNOME Note Pad) on =
Linux.=20
This is very similar in operation to the Microsoft Windows editor, =
"Notepad".=20
(Other Unix systems GUI editors: "dtpad", which can be found in=20
<TT>/usr/dt/bin/dtpad</TT> for AIX, vuepad on HP/UX, or xedit on all =
Unix=20
systems.)=20
<P>
<HR>
<TABLE cellSpacing=3D1 cellPadding=3D4 width=3D"100%" bgColor=3D#000000 =
border=3D1>
<TBODY>
<TR bgColor=3D#cccccc>
<TD vAlign=3Dtop width=3D160 bgColor=3D#c0c0c0>
<P><FONT size=3D-1><B>Related YoLinux Tutorials:</B>=20
<P>=C2=B0<A=20
=
href=3D"http://www.yolinux.com/TUTORIALS/LinuxTutorialSoftwareDevelopment=
.html">Software=20
development tools</A>=20
<P>=C2=B0<A=20
=
href=3D"http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html">A=
dvanced=20
VI</A>=20
<P>=C2=B0<A=20
=
href=3D"http://www.yolinux.com/TUTORIALS/LinuxTutorialXemacs.html">Emacs =
and=20
C/C++</A>=20
<P>=C2=B0<A =
href=3D"http://www.yolinux.com/TUTORIALS/LinuxTutorialC++.html">C++=20
Info, links</A>=20
<P>=C2=B0<A=20
=
href=3D"http://www.yolinux.com/TUTORIALS/MicrosoftVisualC++Tips.html">MS/=
Visual=20
C++ Practices</A>=20
<P>=C2=B0<A=20
=
href=3D"http://www.yolinux.com/TUTORIALS/C++MemoryCorruptionAndMemoryLeak=
s.html">C++=20
Memory corruption and leaks</A>=20
<P>=C2=B0<A=20
=
href=3D"http://www.yolinux.com/TUTORIALS/LinuxTutorialC++StringClass.html=
">C++=20
String Class</A>=20
<P>=C2=B0<A=20
=
href=3D"http://www.yolinux.com/TUTORIALS/LinuxTutorialC++STL.html">C++ =
STL=20
vector, list</A>=20
<P>=C2=B0<A=20
=
href=3D"http://www.yolinux.com/TUTORIALS/LinuxTutorialPosixThreads.html">=
Posix=20
Threads</A>=20
<P>=C2=B0<A =
href=3D"http://www.yolinux.com/TUTORIALS/ForkExecProcesses.html">Fork=20
and Exec</A>=20
<P>=C2=B0<A =
href=3D"http://www.yolinux.com/TUTORIALS/GDK_Threads.html">GDK=20
Threads</A>=20
<P>=C2=B0<A=20
=
href=3D"http://www.yolinux.com/TUTORIALS/ClearcaseCommands.html">Clearcas=
e=20
Commands</A>=20
<P>=C2=B0<A=20
=
href=3D"http://www.yolinux.com/TUTORIALS/index.html#PROGRAMMING">YoLinux =
Tutorials Index</A> </FONT>
<P>
<HR>
<P>
<SCRIPT type=3Dtext/javascript><!--=0A=
google_ad_client =3D "pub-8567479315106986";=0A=
google_ad_width =3D 160;=0A=
google_ad_height =3D 600;=0A=
google_ad_format =3D "160x600_as";=0A=
google_ad_channel =3D"";=0A=
google_color_border =3D ["6699CC","2D5893","191933"];=0A=
google_color_bg =3D ["003366","99AACC","333366"];=0A=
google_color_link =3D ["FFFFFF","000000","99CC33"];=0A=
google_color_url =3D ["AECCEB","000099","FFCC00"];=0A=
google_color_text =3D ["AECCEB","003366","FFFFFF"];=0A=
//--></SCRIPT>
<SCRIPT =
src=3D"http://pagead2.googlesyndication.com/pagead/show_ads.js"=20
type=3Dtext/javascript>=0A=
</SCRIPT>
<P>
<HR>
<P><A href=3D"http://yolinux.tradepub.com/">Free Information =
Technology=20
Magazine Subscriptions and Document Downloads</A>=20
<P>
<HR>
<P><A =
href=3D"http://yolinux.tradepub.com/?pt=3Dcat&page=3DInfosoft">Free=20
Information Technology <B>Software and Development</B> Magazine=20
Subscriptions and Document Downloads</A>=20
<P>
<HR>
<P></P></TD>
<TD vAlign=3Dtop>
<TABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%" border=3D0>
<TBODY>
<TR bgColor=3D#ffcc33>
<TD><B><BIG>Basic "vi" =
features</BIG></B></TD></TR></TBODY></TABLE>
<P>One edits a file in <TT>vi</TT> by issuing the command: <TT>vi=20
file-to-edit.txt</TT>=20
<P>The vi editor has three modes, command mode, insert mode and =
command=20
line mode.=20
<OL>
<LI><B>Command mode:</B> letters or sequence of letters =
interactively=20
command vi. Commands are case sensitive. The ESC key can end a =
command.=20
<LI><B>Insert mode:</B> Text is inserted. The ESC key ends =
insert mode=20
and returns you to command mode. One can enter insert mode with =
the "i"=20
(insert), "a" (insert after), "A" (insert at end of line), "o" =
(open new=20
line after current line) or "O" (Open line above current line) =
commands.=20
<LI><B>Command line mode:</B> One enters this mode by typing ":" =
which=20
puts the command line entry at the foot of the screen. =
</LI></OL>
<P>Partial list of interactive commands:=20
<DL>
<DD><B>Cursor movement:</B>=20
<DL>
<DD>
<TABLE cellPadding=3D2 border=3D1>
<TBODY>
<TR bgColor=3D#c0c0c0>
<TH>Keystrokes</TH>
<TH>Action</TH></TR>
<TR>
<TD>h/j/k/l </TD>
<TD>Move cursor left/down/up/right</TD></TR>
<TR>
<TD>-/+ </TD>
<TD>Move cursor down/up in first column</TD></TR>
<TR>
<TD>ctrl-d</TD>
<TD>Scroll down one half of a page</TD></TR>
<TR>
<TD>ctrl-u</TD>
<TD>Scroll up one half of a page</TD></TR>
<TR>
<TD>ctrl-f</TD>
<TD>Scroll forward one page</TD></TR>
<TR>
<TD>ctrl-b</TD>
<TD>Scroll back one page</TD></TR>
<TR>
<TD>M (shift-h)</TD>
<TD>Move cursor to middle of page</TD></TR>
<TR>
<TD>H</TD>
<TD>Move cursor to top of page</TD></TR>
<TR>
<TD>L</TD>
<TD>Move cursor to bottom of page</TD></TR>
<TR>
<TD>w<BR>5w </TD>
<TD>Move cursor a word at a time<BR>Move cursor ahead 5 =
words=20
</TD></TR>
<TR>
<TD>b<BR>B<BR>5b </TD>
<TD vAlign=3Dtop>Move cursor back a word at a time<BR>Move =
cursor=20
back a word at a time<BR>Move cursor back 5 words =
</TD></TR>
<TR>
<TD>e<BR>5e </TD>
<TD>Move cursor to end of word<BR>Move cursor ahead to the =
end=20
of the 5th word </TD></TR>
<TR>
<TD>0 (zero) </TD>
<TD>Move cursor to beginning of line </TD></TR>
<TR>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -