⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vi and vim editor advanced features.mht

📁 linux下c++编程的好文章
💻 MHT
📖 第 1 页 / 共 5 页
字号:
              <TD>$ </TD>
              <TD>Move cursor to end of line </TD></TR>
            <TR>
              <TD>G </TD>
              <TD>Move cursor to end of file </TD></TR>
            <TR>
              <TD>% </TD>
              <TD>Move cursor to the matching bracket. Place cursor on =
{}[]()=20
                and type "%".</TD></TR>
            <TR>
              <TD>'. </TD>
              <TD>Move cursor to previously modified line. </TD></TR>
            <TR>
              <TD>'a </TD>
              <TD>Move cursor to line mark "a" generated by marking with =

                keystroke "ma"</TD></TR>
            <TR>
              <TD>'A </TD>
              <TD>Move cursor to line mark "a" (global between buffers)=20
                generated by marking with keystroke "mA"</TD></TR>
            <TR>
              <TD>]' </TD>
              <TD>Move cursor to next lower case mark. </TD></TR>
            <TR>
              <TD>[' </TD>
              <TD>Move cursor to previous lower case mark.=20
          </TD></TR></TBODY></TABLE></DD></DL>
        <P><B>Editing commands:</B>=20
        <DL>
          <DD>
          <TABLE cellPadding=3D2 border=3D1>
            <TBODY>
            <TR bgColor=3D#c0c0c0>
              <TH>Keystrokes</TH>
              <TH>Action</TH></TR>
            <TR>
              <TD>i </TD>
              <TD>Insert at cursor</TD></TR>
            <TR>
              <TD>a </TD>
              <TD>Append after cursor </TD></TR>
            <TR>
              <TD>A </TD>
              <TD>Append at end of line </TD></TR>
            <TR>
              <TD>ESC </TD>
              <TD>Terminate insert mode </TD></TR>
            <TR>
              <TD>u</TD>
              <TD>Undo last change </TD></TR>
            <TR>
              <TD>U</TD>
              <TD>Undo all changes to entire line </TD></TR>
            <TR>
              <TD>o </TD>
              <TD>Open a new line </TD></TR>
            <TR>
              <TD>dd<BR>3dd </TD>
              <TD vAlign=3Dtop>Delete line<BR>Delete 3 lines. </TD></TR>
            <TR>
              <TD>D </TD>
              <TD>Delete contents of line after cursor</TD></TR>
            <TR>
              <TD>dw<BR>4dw </TD>
              <TD>Delete word<BR>Delete 4 words </TD></TR>
            <TR>
              <TD>cw </TD>
              <TD>Change word </TD></TR>
            <TR>
              <TD>x</TD>
              <TD>Delete character at cursor </TD></TR>
            <TR>
              <TD>r</TD>
              <TD>Replace character </TD></TR>
            <TR>
              <TD>R</TD>
              <TD>Overwrite characters from cursor onward </TD></TR>
            <TR>
              <TD>~</TD>
              <TD>Change case of individual character </TD></TR>
            <TR>
              <TD>/search_word{CR}</TD>
              <TD>Search for search_word</TD></TR>
            <TR>
              <TD>n</TD>
              <TD>Find next occurrence of=20
        search_word</TD></TR></TBODY></TABLE></DD></DL></DD></DL>
      <P>Terminate session:=20
      <UL>
        <LI>Use command: ZZ <BR>Save changes and quit.=20
        <LI>Use command line: "<TT>:wq</TT>" <BR>Save (write) changes =
and quit.=20
        <LI>Use command line: "<TT>:q!</TT>" <BR>Ignore changes and =
quit. No=20
        changes from last write will be saved. </LI></UL>
      <P>
      <HR>

      <TABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%" border=3D0>
        <TBODY>
        <TR bgColor=3D#ffcc33>
          <TD><B><BIG>Advanced "vi" =
features</BIG></B></TD></TR></TBODY></TABLE>
      <H3>Interactive Commands:</H3>
      <UL>
        <LI><B>Marking a line:</B>=20
        <DL>
          <DD>Any line can be "Book Marked" for a quick cursor return.=20
          <UL>
            <LI>Type the letter "<B>m</B>" and any other letter to =
identify the=20
            line.=20
            <LI>This "marked" line can be referenced by the keystroke =
sequence=20
            "<B>'</B>" and the identifying letter. <BR>Example: =
"<B>mt</B>" will=20
            mark a line by the identifier "t". <BR>"<B>'t"</B> will =
return the=20
            cursor to this line at any time. <BR>A block of text may be =
referred=20
            to by its marked lines. i.e.<B>'t,'b =
</B></LI></UL></DD></DL>
        <LI><B>vi line buffers:</B>=20
        <DL>
          <DD>To capture lines into the buffer:=20
          <UL>
            <LI>Single line: "<B>yy</B>" - yanks a single line (defined =
by=20
            current cursor position) into the buffer=20
            <LI>Multiple lines: "<B>y't</B>" - yanks from current cursor =

            position to the line marked "t"=20
            <LI>Multiple lines: "<B>3yy</B>" - yank 3 lines. Current =
line and=20
            two lines below it. </LI></UL>Copy from buffer to editing =
session:=20
          <UL>
            <LI>"<B>p</B>" - place contents of buffer after current line =
defined=20
            by current cursor position. </LI></UL></DD></DL></LI></UL>
      <H3>Command Line:</H3>
      <UL>
        <LI><B>command options:</B>=20
        <DL>
          <DD>The vi command line interface is available by typing =
"<B>:</B>".=20
          Terminate with a carriage return. <BR>Example commands:=20
          <UL>
            <LI><B>:set all</B> - display all settings of your session.=20
            <LI><B>:set ic</B> - Change default to ignore case for text =
searches=20
            <BR>Default is changed from noignorecase to ignorecase. (ic =
is a=20
            short form otherwise type <B>set ignorecase</B>)=20
            <LI>Common options to set: <BR>
            <TABLE cellPadding=3D2 border=3D1>
              <TBODY>
              <TR bgColor=3D#c0c0c0>
                <TH>Full Command</TH>
                <TH>Short form</TH>
                <TH>Description</TH></TR>
              <TR>
                <TD>autoindent/noautoindent </TD>
                <TD>ai/noai</TD>
                <TD>{CR} returns to indent of previous line</TD></TR>
              <TR>
                <TD>autowrite/noautowrite </TD>
                <TD>aw/noaw</TD>
                <TD>See tags</TD></TR>
              <TR>
                <TD>errorbells/noerrorbells</TD>
                <TD>eb/noeb</TD>
                <TD>Silence error beep </TD></TR>
              <TR>
                <TD>flash/noflash</TD>
                <TD>fl/nofl</TD>
                <TD>Screen flashes upon error (for deaf people or when=20
                  noerrorbells is set)</TD></TR>
              <TR>
                <TD>tabstop=3D8 </TD>
                <TD>ts</TD>
                <TD>Tab key displays 8 spaces</TD></TR>
              <TR>
                <TD>ignorecase/noignorecase </TD>
                <TD>ic/noic</TD>
                <TD>Case sensitive searches</TD></TR>
              <TR>
                <TD>number/nonumber </TD>
                <TD>nu/nonu=20
                <TD>Display line numbers</TD></TR>
              <TR>
                <TD>showmatch/noshowmatch</TD>
                <TD>no abbreviations </TD>
                <TD>Cursor shows matching ")" and "}"</TD></TR>
              <TR>
                <TD>showmode/noshowmode</TD>
                <TD>no abbreviations </TD>
                <TD>Editor mode is displayed on bottom of =
screen</TD></TR>
              <TR>
                <TD>taglength</TD>
                <TD>tl</TD>
                <TD>Default=3D0. Set significant characters</TD></TR>
              <TR>
                <TD>closepunct=3D'".,;)]}</TD>
                <TD>- </TD>
                <TD>% key shows matching symbol. Also see =
showmatch</TD></TR>
              <TR>
                <TD>linelimit=3D1048560 </TD>
                <TD>- </TD>
                <TD>Maximum file size to edit</TD></TR>
              <TR>
                <TD>wrapscan/nowrapscan</TD>
                <TD>ws/nows</TD>
                <TD>Breaks line if too long </TD></TR>
              <TR>
                <TD>wrapmargin=3D0/nowrapmargin</TD>
                <TD>wm/nowm</TD>
                <TD>Define right margin for line wrapping.</TD>
              <TR>
                <TD>list/nolist</TD>
                <TD>- </TD>
                <TD>Display all Tabs/Ends of=20
          lines.</TD></TR></TBODY></TABLE></LI></UL></DD></DL><BR>
        <LI><B>Executing Unix commands in vi:</B>=20
        <DL>
          <DD>Any UNIX command can be executed from the vi command line =
by=20
          typing an "!" before the UNIX command. <BR>Examples:=20
          <UL>
            <LI>"<B>:!pwd</B>" - shows your current working directory.=20
            <LI>"<B>:r !date</B>" - reads the results from the date =
command into=20
            a new line following the cursor.=20
            <LI>"<B>:r !ls -1</B>" - Place after the cursor, the current =

            directory listing displayed as a single column. =
</LI></UL></DD></DL>
        <LI><B>Line numbers:</B>=20
        <DL>
          <DD>Lines may be referenced by their line numbers. The last =
line in=20
          the file can be referenced by the "$" sign. <BR>The entire =
file may be=20
          referenced by the block "<B>1,$</B>" or "<B>%</B>" <BR>The =
current=20
          line is referred to as "<B>.</B>" <BR>A block of text may be =
referred=20
          to by its marked lines. i.e. <B>5,38</B> or <B>'t,'b =
</B></DD></DL>
        <LI><B>Find/Replace:</B>=20
        <DL>
          <DD>Example:=20
          <UL>
            <LI><B>:%s/fff/rrrrr/</B> - For all lines in a file, find =
string=20
            "fff" and replace with string "rrrrr" for the first instance =
on a=20
            line.=20
            <LI><B>:%s/fff/rrrrr/g</B> - For all lines in a file, find =
string=20
            "fff" and replace with string "rrrrr" for each instance on a =
line.=20
            <LI><B>:%s/fff/rrrrr/gc</B> - For all lines in a file, find =
string=20
            "fff" and replace with string "rrrrr" for each instance on a =
line.=20
            Ask for confirmation=20
            <LI><B>:%s/fff/rrrrr/gi</B> - For all lines in a file, find =
string=20
            "fff" and replace with string "rrrrr" for each instance on a =
line.=20
            Case insensitive.=20
            <LI><B>:'a,'bs/fff/rrrrr/gi</B> - For all lines between line =
marked=20
            "a" (ma) and line marked "b" (mb), find string "fff" and =
replace=20
            with string "rrrrr" for each instance on a line. Case =
insensitive.=20
            <LI><B>:%s/*$/</B> - For all lines in a file, delete blank =
spaces at=20
            end of line.=20
            <LI><B>:%s/\(.*\):\(.*\)/\2:\1/g</B> - For all lines in a =
file, move=20
            last field delimited by ":" to the first field. Swap fields =
if only=20
            two. </LI></UL>For more info type:=20
          <UL>
            <LI><B>:help substitute</B>=20
            <LI><B>:help pattern</B>=20
            <LI><B>:help gdefault</B>=20
            <LI><B>:help cmdline-ranges</B> </LI></UL></DD></DL>
        <LI><B>Sorting:</B>=20
        <DL>
          <DD>Example:
          <UL>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -