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

📄 vi and vim editor advanced features.mht

📁 linux下c++编程的好文章
💻 MHT
📖 第 1 页 / 共 5 页
字号:
            <LI>Mark a block of text at the top line and bottom line of =
the=20
            block. i.e. "<B>mt</B>" and "<B>mb</B>" on two separate =
lines.=20
            <LI><B>:'t,'b !sort</B> </LI></UL></DD></DL><BR>
        <LI><B>Moving columns, manipulating fields and awk:</B>=20
        <DL>
          <DD><B>:'t,. !awk '{print $3 " " $2 " " $1}' </B>- This will =
reverse=20
          the order of the columns in the block. <BR><PRE>              =
aaa bbb ccc              ccc bbb aaa
              xxx yyy zzz   becomes-&gt;  zzz yyy xxx
              111 222 333              333 222 111
              </PRE></DD></DL>
        <LI><B>Formatting:</B>=20
        <DL>
          <DD>
          <LI>Mark a block of text at the top line and bottom line of =
the block.=20
          i.e. "<B>mt</B>" and "<B>mb</B>" on two separate lines.=20
          <LI>Example: "<B>:'t,'b !nroff</B>"=20
          <LI>You can insert nroff commands i.e.:=20
          <UL>
            <TABLE cellPadding=3D2 border=3D1>
              <TBODY>
              <TR>
                <TD>.ce 3</TD>
                <TD>Center the next three lines</TD></TR>
              <TR>
                <TD>.fi</TD>
                <TD>Fill text - left and right justify =
(default)</TD></TR>
              <TR>
                <TD>.nf </TD>
                <TD>No Fill</TD></TR>
              <TR>
                <TD>.ls 2 </TD>
                <TD>Double line spacing</TD></TR>
              <TR>
                <TD>.sp </TD>
                <TD>Single line space</TD></TR>
              <TR>
                <TD>.sv 1.0i</TD>
                <TD>Vertical space at top of page space</TD></TR>
              <TR>
                <TD>.ns </TD>
                <TD>Turn off spacing mode</TD></TR>
              <TR>
                <TD>.rs </TD>
                <TD>Restore spacing mode</TD></TR>
              <TR>
                <TD>.ll 6.0i </TD>
                <TD>Line length =3D 6 inches</TD></TR>
              <TR>
                <TD>.in 1.0i </TD>
                <TD>Indent one inch</TD></TR>
              <TR>
                <TD>.ti 1.0i </TD>
                <TD>Temporarily one time only indent one inch</TD></TR>
              <TR>
                <TD>.pl 8.0i </TD>
                <TD>Page length =3D 8 inches</TD></TR>
              <TR>
                <TD>.bp </TD>
                <TD>Page break</TD></TR></TBODY></TABLE></UL>
          <P>
          <DL>
            <DD>
            <TABLE cellSpacing=3D1 cellPadding=3D4 width=3D"100%" =
bgColor=3D#000000=20
            border=3D1>
              <TBODY>
              <TR bgColor=3D#c0c0c0>
                <TD><PRE>.fi
.pl 2i
.in 1.0i
.ll 6.0i
.ce
Title to be centered
.sp
The following text bla bla bla bla bla bla bla bla bla bla=20
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla=20
bla bla bla bla bla bla bla bla bla bla bla bla bla bla=20
bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla=20
bla bla bla bla bla
</PRE></TD></TR></TBODY></TABLE></DD></DL>
          <P>Becomes:=20
          <DL>
            <DD>
            <TABLE cellSpacing=3D1 cellPadding=3D4 width=3D"100%" =
bgColor=3D#000000=20
            border=3D1>
              <TBODY>
              <TR bgColor=3D#c0c0c0>
                <TD><PRE>                         Title to be centered

          The following text bla bla bla bla bla bla bla bla
          bla  bla  bla  bla bla bla bla bla bla bla bla bla
          bla bla bla bla bla bla bla bla bla  bla  bla  bla
          bla  bla  bla  bla bla bla bla bla bla bla bla bla
          bla bla bla bla bla bla bla bla bla  bla  bla  bla
          bla bla bla bla




</PRE></TD></TR></TBODY></TABLE></DD></DL></LI></DD></DL>
        <LI><B>Spell Checking:</B>=20
        <DL>
          <DD>
          <UL>
            <LI>Mark a block of text by marking the top line and bottom =
line of=20
            the block. i.e. "<B>mt</B>" and "<B>mb</B>" on two separate =
lines.=20
            <LI><B>:'t,'b !spell</B> will cause the block to be replaced =
with=20
            misspelled words.=20
            <LI>Press "<B>u</B>" to undo.=20
            <LI>Proceed to correct words misspelled. =
</LI></UL></DD></DL>
        <LI><B>Macros:</B>=20
        <DL>
          <DD><B>:map letter commands_strung_together</B> =
<BR><B>:map</B> -=20
          lists current key mappings <BR>Example - <B>:map g n=20
          cwNEW_WORD{ctrl-v}{esc}i{ctrl-v}{CR} </B><BR>This example =
would find=20
          the next search occurrence, change the word and insert a line =
feed=20
          after the word. The macro is invoked by typing the letter "g". =

          <P>
          <UL>
            <LI>Control/Escape/Carriage control characters must be =
prefixed with=20
            ctrl-V.=20
            <LI>Choose a letter which is not used or important. (i.e. a =
poor=20
            choice would be "i" as this is used for insert) =
</LI></UL></DD></DL>
        <P></P>
        <LI><B>Double spacing:</B>=20
        <UL>
          <LI><B>:%s/$/{ctrl-V}{CR}/g</B> <BR>This command applies an =
extra=20
          carriage return at the end of all lines </LI></UL>
        <P></P>
        <LI><B>Strip blanks at end of line:</B>=20
        <UL>
          <LI><B>:%s/{TAB}*$//</B> </LI></UL>
        <P></P>
        <LI><B>Strip DOS ctrl-M's:</B>=20
        <UL>
          <LI><B>:1,$ s/{ctrl-V}{ctrl-M}//</B> </LI></UL><BR>Note: In =
order to=20
        enter a control character, one muust first enter ctrl-v. This is =
true=20
        throughout vi. For example, if searching for a control character =
(i.e.=20
        ctrl-m): <TT>/ctrl-v ctrl-M</TT> If generating a macro and you =
need to=20
        enter esc without exiting the vi command line the esc must be =
prefixed=20
        with a ctrl-v: <TT>ctrl-v esc</TT>.=20
        <P></P>
        <LI><B>Editing multiple files:</B>=20
        <UL>
          <LI><B>vi file1 file2 file3</B>=20
          <LI><B>:n</B> Edit next file (file2)=20
          <LI><B>:n</B> Edit next file (file3)=20
          <LI><B>:rew</B> Rewind to the first file (file1) </LI></UL>
        <P></P>
        <LI><B>Batch execution of vi from a command file:</B> =
<BR>Command file=20
        to change HTML file to lower case and XHTML compiance:=20
        <DL>
          <DD>
          <TABLE cellSpacing=3D1 cellPadding=3D4 width=3D"100%" =
bgColor=3D#000000=20
          border=3D1>
            <TBODY>
            <TR bgColor=3D#c0c0c0>
              <TD><PRE>:1,$ s/&lt;HTML&gt;/&lt;html&gt;/g
:1,$ s/&lt;\/HTML&gt;/&lt;\/html&gt;/g
:1,$ s/&lt;HEAD&gt;/&lt;head&gt;/g
:1,$ s/&lt;\/HEAD&gt;/&lt;\/head&gt;/g
:1,$ s/&lt;TITLE&gt;/&lt;title&gt;/g
:1,$ s/&lt;\/TITLE&gt;/&lt;\/title&gt;/g
:1,$ s/&lt;BODY/&lt;body/g
:1,$ s/&lt;\/BODY/&lt;\/body/g
:1,$ s/&lt;UL&gt;/&lt;ul&gt;/g
:1,$ s/&lt;\/UL&gt;/&lt;\/ul&gt;/g
...
..
.
:1,$ s/&lt;A HREF/&lt;a href/g
:1,$ s/&lt;A NAME/&lt;a name/g
:1,$ s/&lt;\/A&gt;/&lt;\/a&gt;/g
:1,$ s/&lt;P&gt;/&lt;p&gt;/g
:1,$ s/&lt;B&gt;/&lt;b&gt;/g
:1,$ s/&lt;\/B&gt;/&lt;\/b&gt;/g
:1,$ s/&lt;I&gt;/&lt;i&gt;/g
:1,$ s/&lt;\/I&gt;/&lt;\/i&gt;/g
:wq
       </PRE></TD></TR></TBODY></TABLE></DD></DL>Execute: <TT>vi -e=20
        <I>file-name</I>.html &lt; <A=20
        =
href=3D"http://www.yolinux.com/TUTORIALS/ViCommands-HtmlUpdate.txt">ViCom=
mands-HtmlUpdate.txt</A></TT>=20
        </LI></UL>
      <P>
      <HR>

      <TABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%" border=3D0>
        <TBODY>
        <TR bgColor=3D#ffcc33>
          <TD><B><BIG>Tagging:</BIG></B></TD></TR></TBODY></TABLE>
      <P>This functionality allows one to jump between files to locate=20
      subroutines.=20
      <DL>
        <DD>
        <UL>
          <LI><B>ctags *.h *.c</B> This creates a file names "tags".=20
        </LI></UL></DD></DL>
      <P>Edit the file using <B>vi</B>.=20
      <DL>
        <DD>
        <UL>
          <LI>Unix command line: <B><TT>vi -t &nbsp; subroutine_name=20
          </TT></B>This will find the correct file to edit. <BR>OR=20
          <LI>Vi command line: <B><TT>:tag subroutine_name</TT></B> This =
will=20
          jump from your current file to the file containing the =
subroutine.=20
          (short form <B><TT>:ta subroutine_name</TT></B> ) <BR>OR=20
          <LI>By cursor position: <B>ctrl-]</B> Place cursor on the =
first=20
          character of the subroutine name and press <B>ctrl-]</B> This =
will=20
          jump to the file containing the subroutine. <BR><B>Note:</B> =
The key=20
          combination <TT>ctrl-]</TT> is also the default telnet =
connection=20
          interrupt. To avoid this problem when using telnet block this =
telnet=20
          escape key by specifying NULL or a new escape key:=20
          <UL>
            <LI><TT>telnet -E <I>file-name</I></TT>=20
            <LI><TT>telnet -e "" <I>file-name</I></TT> =
</LI></UL></LI></UL></DD></DL>
      <P>In all cases you will be entered into the correct file and the =
cursor=20
      will be positioned at the subroutine desired. <BR>If it is not =
working=20
      properly look at the "tags" file created by <B>ctags</B>. Also the =
tag=20
      name (first column) may be abbreviated for convenience. One may =
shorten=20
      the significant characters using <B>:set taglength=3Dnumber</B>=20
      <P>Tag Notes:=20
      <UL>
        <LI>A project may have a tags file which can be added and =
referred to=20
        by: <B><TT>:set tags=3Dtags\ /ad/src/project1.tags</TT></B> =
<BR>A "\" must=20
        separate the file names.=20
        <LI><B><TT>:set autowrite</TT></B> will automatically save =
changes when=20
        jumping from file to file, otherwise you need to use the =
<B>:w</B>=20
        command. </LI></UL>
      <P><B>vim tagging notes:</B> (These specific tag features not =
available in=20
      vi)=20
      <TABLE border=3D1>
        <TBODY>
        <TR bgColor=3D#c0c0c0>
          <TH>Tag Command</TH>
          <TH>Description</TH></TR>
        <TR>
          <TD><TT>:tag <I>start-of-tag-name_</I>TAB</TT></TD>
          <TD>Vim supports tag name completion. Start the typing the tag =
name=20
            and then type the TAB key and name completion will complete =
the tag=20
            name for you.</TD></TR>
        <TR>
          <TD><TT>:tag /<I>search-string</I></TT></TD>
          <TD>Jump to a tag name found by a search.</TD></TR>
        <TR>
          <TD vAlign=3Dtop><B><TT>ctrl-t</TT></B></TD>
          <TD>The vim editor will allow the user to jump back a level. =
<BR>(or=20
            <TT>:pop</TT>)</TD></TR>
        <TR>
          <TD vAlign=3Dtop><B><TT>:tselect=20
          <I>&lt;function-name&gt;</I></TT></B></TD>
          <TD>When multiple entries exist in the tags file, such as a =

⌨️ 快捷键说明

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