1 Star 0 Fork 0

hilarryxu/vimdoc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
usr_04.html 47.32 KB
一键复制 编辑 原始数据 按行查看 历史
hilarryxu 提交于 2017-08-15 10:58 . Init repo
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>usr_04 - Vim Documentation</title>
<meta name="Generator" content="Vim/8.0">
<meta name="plugin-version" content="vim8.0">
<meta name="syntax" content="help">
<meta name="settings" content="no_pre,use_css,expand_tabs">
<link rel="stylesheet" href="style.css" type="text/css" />
<script src="jquery.min.js" type="text/javascript"></script>
<script src="mark-current-page.js" type="text/javascript"></script>
</head>
<body>
<header>
<div class="header">
<a href="http://vim-jp.org/">vim-jp</a>
/ <a href="http://vim-jp.org/vimdoc-en/">vimdoc-en</a>
/ usr_04<br />
<a name="top"></a><h1>usr_04 - Vim Documentation</h1>
<a href="index.html">Return to main</a>
<span class="EnglishJapaneseLink">
<span class="CurrentLanguage">English</span>
</span>
</div>
</header>
<nav>
<dl>
<dt>BASIC</dt>
<dd><ul>
<li><a href="quickref.html">quickref</a></li>
<li><a href="sponsor.html">sponsor</a></li>
</ul></dd>
<dt>USER MANUAL</dt>
<dd><ul>
<li><a href="usr_toc.html">usr_toc</a></li>
</ul></dd>
<dt>Getting Started</dt>
<dd><ul>
<li><a href="usr_01.html">usr_01</a></li>
<li><a href="usr_02.html">usr_02</a></li>
<li><a href="usr_03.html">usr_03</a></li>
<li><a href="usr_04.html">usr_04</a></li>
<li><a href="usr_05.html">usr_05</a></li>
<li><a href="usr_06.html">usr_06</a></li>
<li><a href="usr_07.html">usr_07</a></li>
<li><a href="usr_08.html">usr_08</a></li>
<li><a href="usr_09.html">usr_09</a></li>
<li><a href="usr_10.html">usr_10</a></li>
<li><a href="usr_11.html">usr_11</a></li>
<li><a href="usr_12.html">usr_12</a></li>
</ul></dd>
<dt>Editing Effectively</dt>
<dd><ul>
<li><a href="usr_20.html">usr_20</a></li>
<li><a href="usr_21.html">usr_21</a></li>
<li><a href="usr_22.html">usr_22</a></li>
<li><a href="usr_23.html">usr_23</a></li>
<li><a href="usr_24.html">usr_24</a></li>
<li><a href="usr_25.html">usr_25</a></li>
<li><a href="usr_26.html">usr_26</a></li>
<li><a href="usr_27.html">usr_27</a></li>
<li><a href="usr_28.html">usr_28</a></li>
<li><a href="usr_29.html">usr_29</a></li>
<li><a href="usr_30.html">usr_30</a></li>
<li><a href="usr_31.html">usr_31</a></li>
<li><a href="usr_32.html">usr_32</a></li>
</ul></dd>
<dt>Tuning Vim</dt>
<dd><ul>
<li><a href="usr_40.html">usr_40</a></li>
<li><a href="usr_41.html">usr_41</a></li>
<li><a href="usr_42.html">usr_42</a></li>
<li><a href="usr_43.html">usr_43</a></li>
<li><a href="usr_44.html">usr_44</a></li>
<li><a href="usr_45.html">usr_45</a></li>
</ul></dd>
<dt>Making Vim Run</dt>
<dd><ul>
<li><a href="usr_90.html">usr_90</a></li>
</ul></dd>
<dt>General subjects</dt>
<dd><ul>
<li><a href="intro.html">intro</a></li>
<li><a href="index.html">help</a></li>
<li><a href="helphelp.html">helphelp</a></li>
<li><a href="vimindex.html">index</a></li>
<li><a href="tags.html">tags</a></li>
<li><a href="howto.html">howto</a></li>
<li><a href="tips.html">tips</a></li>
<li><a href="message.html">message</a></li>
<li><a href="quotes.html">quotes</a></li>
<li><a href="todo.html">todo</a></li>
<li><a href="debug.html">debug</a></li>
<li><a href="develop.html">develop</a></li>
<li><a href="uganda.html">uganda</a></li>
</ul></dd>
<dt>Basic editing</dt>
<dd><ul>
<li><a href="starting.html">starting</a></li>
<li><a href="editing.html">editing</a></li>
<li><a href="motion.html">motion</a></li>
<li><a href="scroll.html">scroll</a></li>
<li><a href="insert.html">insert</a></li>
<li><a href="change.html">change</a></li>
<li><a href="indent.html">indent</a></li>
<li><a href="undo.html">undo</a></li>
<li><a href="repeat.html">repeat</a></li>
<li><a href="visual.html">visual</a></li>
<li><a href="various.html">various</a></li>
<li><a href="recover.html">recover</a></li>
</ul></dd>
<dt>Advanced editing</dt>
<dd><ul>
<li><a href="cmdline.html">cmdline</a></li>
<li><a href="options.html">options</a></li>
<li><a href="pattern.html">pattern</a></li>
<li><a href="map.html">map</a></li>
<li><a href="tagsrch.html">tagsrch</a></li>
<li><a href="quickfix.html">quickfix</a></li>
<li><a href="windows.html">windows</a></li>
<li><a href="tabpage.html">tabpage</a></li>
<li><a href="syntax.html">syntax</a></li>
<li><a href="spell.html">spell</a></li>
<li><a href="diff.html">diff</a></li>
<li><a href="autocmd.html">autocmd</a></li>
<li><a href="filetype.html">filetype</a></li>
<li><a href="eval.html">eval</a></li>
<li><a href="channel.html">channel</a></li>
<li><a href="fold.html">fold</a></li>
</ul></dd>
<dt>Special issues</dt>
<dd><ul>
<li><a href="print.html">print</a></li>
<li><a href="remote.html">remote</a></li>
<li><a href="term.html">term</a></li>
<li><a href="digraph.html">digraph</a></li>
<li><a href="mbyte.html">mbyte</a></li>
<li><a href="mlang.html">mlang</a></li>
<li><a href="arabic.html">arabic</a></li>
<li><a href="farsi.html">farsi</a></li>
<li><a href="hebrew.html">hebrew</a></li>
<li><a href="russian.html">russian</a></li>
<li><a href="ft_ada.html">ft_ada</a></li>
<li><a href="ft_sql.html">ft_sql</a></li>
<li><a href="hangulin.html">hangulin</a></li>
<li><a href="rileft.html">rileft</a></li>
</ul></dd>
<dt>GUI</dt>
<dd><ul>
<li><a href="gui.html">gui</a></li>
<li><a href="gui_w32.html">gui_w32</a></li>
<li><a href="gui_x11.html">gui_x11</a></li>
</ul></dd>
<dt>Interfaces</dt>
<dd><ul>
<li><a href="if_cscop.html">if_cscop</a></li>
<li><a href="if_lua.html">if_lua</a></li>
<li><a href="if_mzsch.html">if_mzsch</a></li>
<li><a href="if_perl.html">if_perl</a></li>
<li><a href="if_pyth.html">if_pyth</a></li>
<li><a href="if_tcl.html">if_tcl</a></li>
<li><a href="if_ole.html">if_ole</a></li>
<li><a href="if_ruby.html">if_ruby</a></li>
<li><a href="debugger.html">debugger</a></li>
<li><a href="workshop.html">workshop</a></li>
<li><a href="netbeans.html">netbeans</a></li>
<li><a href="sign.html">sign</a></li>
</ul></dd>
<dt>Versions</dt>
<dd><ul>
<li><a href="vi_diff.html">vi_diff</a></li>
<li><a href="version4.html">version4</a></li>
<li><a href="version5.html">version5</a></li>
<li><a href="version6.html">version6</a></li>
<li><a href="version7.html">version7</a></li>
<li><a href="version8.html">version8</a></li>
</ul></dd>
<dt>Remarks about specific systems</dt>
<dd><ul>
<li><a href="os_390.html">os_390</a></li>
<li><a href="os_amiga.html">os_amiga</a></li>
<li><a href="os_beos.html">os_beos</a></li>
<li><a href="os_dos.html">os_dos</a></li>
<li><a href="os_mac.html">os_mac</a></li>
<li><a href="os_mint.html">os_mint</a></li>
<li><a href="os_msdos.html">os_msdos</a></li>
<li><a href="os_os2.html">os_os2</a></li>
<li><a href="os_qnx.html">os_qnx</a></li>
<li><a href="os_risc.html">os_risc</a></li>
<li><a href="os_unix.html">os_unix</a></li>
<li><a href="os_vms.html">os_vms</a></li>
<li><a href="os_win32.html">os_win32</a></li>
</ul></dd>
<dt>Standard plugins</dt>
<dd><ul>
<li><a href="pi_getscript.html">pi_getscript</a></li>
<li><a href="pi_gzip.html">pi_gzip</a></li>
<li><a href="pi_logipat.html">pi_logipat</a></li>
<li><a href="pi_netrw.html">pi_netrw</a></li>
<li><a href="pi_paren.html">pi_paren</a></li>
<li><a href="pi_tar.html">pi_tar</a></li>
<li><a href="pi_vimball.html">pi_vimball</a></li>
<li><a href="pi_zip.html">pi_zip</a></li>
</ul></dd>
<dt>Filetype plugins</dt>
<dd><ul>
<li><a href="pi_spec.html">pi_spec</a></li>
</ul></dd>
<dt>Others</dt>
<dd><ul>
<li><a href="vim_faq.html">vim_faq</a></li>
</ul></dd>
</dl>
</nav>
<article class="Vimdoc VimdocJa">
<div id='vimCodeElement'>
<a class="Constant" href="usr_04.html" name="usr_04.txt">usr_04.txt</a>&nbsp;&nbsp;&nbsp;&nbsp;For&nbsp;<span class="Identifier">Vim version 8.0.</span>&nbsp;&nbsp;Last change: 2014 Aug 29<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VIM USER MANUAL - by Bram Moolenaar<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Making small changes<br>
<br>
<br>
This chapter shows you several ways of making corrections and moving text<br>
around.&nbsp;&nbsp;It teaches you the three basic ways to change text: operator-motion,<br>
Visual mode and text objects.<br>
<br>
<a class="Identifier" href="usr_04.html#04.1">04.1</a>&nbsp;&nbsp;Operators and motions<br>
<a class="Identifier" href="usr_04.html#04.2">04.2</a>&nbsp;&nbsp;Changing text<br>
<a class="Identifier" href="usr_04.html#04.3">04.3</a>&nbsp;&nbsp;Repeating a change<br>
<a class="Identifier" href="usr_04.html#04.4">04.4</a>&nbsp;&nbsp;Visual mode<br>
<a class="Identifier" href="usr_04.html#04.5">04.5</a>&nbsp;&nbsp;Moving text<br>
<a class="Identifier" href="usr_04.html#04.6">04.6</a>&nbsp;&nbsp;Copying text<br>
<a class="Identifier" href="usr_04.html#04.7">04.7</a>&nbsp;&nbsp;Using the clipboard<br>
<a class="Identifier" href="usr_04.html#04.8">04.8</a>&nbsp;&nbsp;Text objects<br>
<a class="Identifier" href="usr_04.html#04.9">04.9</a>&nbsp;&nbsp;Replace mode<br>
<a class="Identifier" href="usr_04.html#04.10">04.10</a>&nbsp;Conclusion<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp; Next chapter:&nbsp;<a class="Identifier" href="usr_05.html">usr_05.txt</a>&nbsp;&nbsp;Set your settings<br>
&nbsp;Previous chapter:&nbsp;<a class="Identifier" href="usr_03.html">usr_03.txt</a>&nbsp;&nbsp;Moving around<br>
Table of contents:&nbsp;<a class="Identifier" href="usr_toc.html">usr_toc.txt</a><br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_04.html#04.1" name="04.1">04.1</a>&nbsp;&nbsp;Operators and motions<br>
<br>
In chapter 2 you learned the &quot;x&quot; command to delete a single character.&nbsp;&nbsp;And<br>
using a count: &quot;4x&quot; deletes four characters.<br>
&nbsp;&nbsp; The &quot;dw&quot; command deletes a word.&nbsp;&nbsp;You may recognize the &quot;w&quot; command as the<br>
move word command.&nbsp;&nbsp;In fact, the &quot;d&quot; command may be followed by any motion<br>
command, and it deletes from the current location to the place where the<br>
cursor winds up.<br>
&nbsp;&nbsp; The &quot;4w&quot; command, for example, moves the cursor over four words.&nbsp;&nbsp;The d4w<br>
command deletes four words.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">To err is human. To really foul up you need a computer.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ------------------&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d4w<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">To err is human. you need a computer.</span><br>
<br>
Vim only deletes up to the position where the motion takes the cursor.&nbsp;&nbsp;That's<br>
because Vim knows that you probably don't want to delete the first character<br>
of a word.&nbsp;&nbsp;If you use the &quot;e&quot; command to move to the end of a word, Vim<br>
guesses that you do want to include that last character:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">To err is human. you need a computer.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;--------&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; d2e<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">To err is human. a computer.</span><br>
<br>
Whether the character under the cursor is included depends on the command you<br>
used to move to that character.&nbsp;&nbsp;The reference manual calls this &quot;exclusive&quot;<br>
when the character isn't included and &quot;inclusive&quot; when it is.<br>
<br>
The &quot;$&quot; command moves to the end of a line.&nbsp;&nbsp;The &quot;d$&quot; command deletes from the<br>
cursor to the end of the line.&nbsp;&nbsp;This is an inclusive motion, thus the last<br>
character of the line is included in the delete operation:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">To err is human. a computer.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ------------&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;d$<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">To err is human</span><br>
<br>
There is a pattern here: operator-motion.&nbsp;&nbsp;You first type an operator command.<br>
For example, &quot;d&quot; is the delete operator.&nbsp;&nbsp;Then you type a motion command like<br>
&quot;4l&quot; or &quot;w&quot;.&nbsp;&nbsp;This way you can operate on any text you can move over.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_04.html#04.2" name="04.2">04.2</a>&nbsp;&nbsp;Changing text<br>
<br>
Another operator is &quot;c&quot;, change.&nbsp;&nbsp;It acts just like the &quot;d&quot; operator, except<br>
it leaves you in Insert mode.&nbsp;&nbsp;For example, &quot;cw&quot; changes a word.&nbsp;&nbsp;Or more<br>
specifically, it deletes a word and then puts you in Insert mode.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">To err is human</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -------&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c2wbe<span class="Special">&lt;Esc&gt;</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">To be human</span><br>
<br>
This &quot;c2wbe<span class="Special">&lt;Esc&gt;</span>&quot; contains these bits:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; the change operator<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2w&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;move two words (they are deleted and Insert mode started)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;be&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;insert this text<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="Special">&lt;Esc&gt;</span>&nbsp;&nbsp; back to Normal mode<br>
<br>
If you have paid attention, you will have noticed something strange: The space<br>
before &quot;human&quot; isn't deleted.&nbsp;&nbsp;There is a saying that for every problem there<br>
is an answer that is simple, clear, and wrong.&nbsp;&nbsp;That is the case with the<br>
example used here for the &quot;cw&quot; command.&nbsp;&nbsp;The c operator works just like the<br>
d operator, with one exception: &quot;cw&quot;.&nbsp;&nbsp;It actually works like &quot;ce&quot;, change to<br>
end of word.&nbsp;&nbsp;Thus the space after the word isn't included.&nbsp;&nbsp;This is an<br>
exception that dates back to the old Vi.&nbsp;&nbsp;Since many people are used to it<br>
now, the inconsistency has remained in Vim.<br>
<br>
<br>
MORE CHANGES<br>
<br>
Like &quot;dd&quot; deletes a whole line, &quot;cc&quot; changes a whole line.&nbsp;&nbsp;It keeps the<br>
existing indent (leading white space) though.<br>
<br>
Just like &quot;d$&quot; deletes until the end of the line, &quot;c$&quot; changes until the end<br>
of the line.&nbsp;&nbsp;It's like doing &quot;d$&quot; to delete the text and then &quot;a&quot; to start<br>
Insert mode and append new text.<br>
<br>
<br>
SHORTCUTS<br>
<br>
Some operator-motion commands are used so often that they have been given a<br>
single letter command:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x&nbsp;&nbsp;stands for&nbsp;&nbsp;dl&nbsp;&nbsp;(delete character under the cursor)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X&nbsp;&nbsp;stands for&nbsp;&nbsp;dh&nbsp;&nbsp;(delete character left of the cursor)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;D&nbsp;&nbsp;stands for&nbsp;&nbsp;d$&nbsp;&nbsp;(delete to end of the line)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;C&nbsp;&nbsp;stands for&nbsp;&nbsp;c$&nbsp;&nbsp;(change to end of the line)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;s&nbsp;&nbsp;stands for&nbsp;&nbsp;cl&nbsp;&nbsp;(change one character)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;S&nbsp;&nbsp;stands for&nbsp;&nbsp;cc&nbsp;&nbsp;(change a whole line)<br>
<br>
<br>
WHERE TO PUT THE COUNT<br>
<br>
The commands &quot;3dw&quot; and &quot;d3w&quot; delete three words.&nbsp;&nbsp;If you want to get really<br>
picky about things, the first command, &quot;3dw&quot;, deletes one word three times;<br>
the command &quot;d3w&quot; deletes three words once.&nbsp;&nbsp;This is a difference without a<br>
distinction.&nbsp;&nbsp;You can actually put in two counts, however.&nbsp;&nbsp;For example,<br>
&quot;3d2w&quot; deletes two words, repeated three times, for a total of six words.<br>
<br>
<br>
REPLACING WITH ONE CHARACTER<br>
<br>
The &quot;r&quot; command is not an operator.&nbsp;&nbsp;It waits for you to type a character, and<br>
will replace the character under the cursor with it.&nbsp;&nbsp;You could do the same<br>
with &quot;cl&quot; or with the &quot;s&quot; command, but with &quot;r&quot; you don't have to press&nbsp;<span class="Special">&lt;Esc&gt;</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">there is somerhing grong here</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rt&nbsp;&nbsp;&nbsp;&nbsp;rw<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">There is something wrong here</span><br>
<br>
Using a count with &quot;r&quot; causes that many characters to be replaced with the<br>
same character.&nbsp;&nbsp;Example:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">There is something wrong here</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5rx<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">There is something xxxxx here</span><br>
<br>
To replace a character with a line break use &quot;r<span class="Special">&lt;Enter&gt;</span>&quot;.&nbsp;&nbsp;This deletes one<br>
character and inserts a line break.&nbsp;&nbsp;Using a count here only applies to the<br>
number of characters deleted: &quot;4r<span class="Special">&lt;Enter&gt;</span>&quot; replaces four characters with one<br>
line break.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_04.html#04.3" name="04.3">04.3</a>&nbsp;&nbsp;Repeating a change<br>
<br>
The &quot;.&quot; command is one of the most simple yet powerful commands in Vim.&nbsp;&nbsp;It<br>
repeats the last change.&nbsp;&nbsp;For instance, suppose you are editing an HTML file<br>
and want to delete all the&nbsp;<span class="Special">&lt;B&gt;</span>&nbsp;tags.&nbsp;&nbsp;You position the cursor on the first &lt;<br>
and delete the&nbsp;<span class="Special">&lt;B&gt;</span>&nbsp;with the command &quot;df&gt;&quot;.&nbsp;&nbsp;You then go to the &lt; of the next<br>
&lt;/B&gt; and kill it using the &quot;.&quot; command.&nbsp;&nbsp;The &quot;.&quot; command executes the last<br>
change command (in this case, &quot;df&gt;&quot;).&nbsp;&nbsp;To delete another tag, position the<br>
cursor on the &lt; and use the &quot;.&quot; command.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">To &lt;B&gt;generate&lt;/B&gt; a table of &lt;B&gt;contents</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f&lt;&nbsp;&nbsp; find first &lt;&nbsp;&nbsp;&nbsp;&nbsp; ---&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;df&gt;&nbsp;&nbsp;delete to &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f&lt;&nbsp;&nbsp; find next &lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---------&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.&nbsp;&nbsp;&nbsp;&nbsp;repeat df&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ---&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;f&lt;&nbsp;&nbsp; find next &lt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -------------&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.&nbsp;&nbsp;&nbsp;&nbsp;repeat df&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --&gt;<br>
<br>
The &quot;.&quot; command works for all changes you make, except for the &quot;u&quot; (undo),<br>
<span class="Special">CTRL-R</span>&nbsp;(redo) and commands that start with a colon (:).<br>
<br>
Another example: You want to change the word &quot;four&quot; to &quot;five&quot;.&nbsp;&nbsp;It appears<br>
several times in your text.&nbsp;&nbsp;You can do this quickly with this sequence of<br>
commands:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/four<span class="Special">&lt;Enter&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp;find the first string &quot;four&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cwfive<span class="Special">&lt;Esc&gt;</span>&nbsp;&nbsp;&nbsp;&nbsp; change the word to &quot;five&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; find the next &quot;four&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; repeat the change to &quot;five&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; find the next &quot;four&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; repeat the change<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;etc.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_04.html#04.4" name="04.4">04.4</a>&nbsp;&nbsp;Visual mode<br>
<br>
To delete simple items the operator-motion changes work quite well.&nbsp;&nbsp;But often<br>
it's not so easy to decide which command will move over the text you want to<br>
change.&nbsp;&nbsp;Then you can use Visual mode.<br>
<br>
You start Visual mode by pressing &quot;v&quot;.&nbsp;&nbsp;You move the cursor over the text you<br>
want to work on.&nbsp;&nbsp;While you do this, the text is highlighted.&nbsp;&nbsp;Finally type<br>
the operator command.<br>
&nbsp;&nbsp; For example, to delete from halfway one word to halfway another word:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">This is an examination sample of visual mode</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----------&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; velllld<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">This is an example of visual mode</span><br>
<br>
When doing this you don't really have to count how many times you have to<br>
press &quot;l&quot; to end up in the right position.&nbsp;&nbsp;You can immediately see what text<br>
will be deleted when you press &quot;d&quot;.<br>
<br>
If at any time you decide you don't want to do anything with the highlighted<br>
text, just press&nbsp;<span class="Special">&lt;Esc&gt;</span>&nbsp;and Visual mode will stop without doing anything.<br>
<br>
<br>
SELECTING LINES<br>
<br>
If you want to work on whole lines, use &quot;V&quot; to start Visual mode.&nbsp;&nbsp;You will<br>
see right away that the whole line is highlighted, without moving around.<br>
When you move left or right nothing changes.&nbsp;&nbsp;When you move up or down the<br>
selection is extended whole lines at a time.<br>
&nbsp;&nbsp; For example, select three lines with &quot;Vjj&quot;:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+------------------------+<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| text more text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;&gt; | more text more text&nbsp;&nbsp;&nbsp;&nbsp;| |<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;selected lines &gt;&gt; | text text text&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; | | Vjj<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &gt;&gt; | text more&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| V<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| more text more&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+------------------------+<br>
<br>
<br>
SELECTING BLOCKS<br>
<br>
If you want to work on a rectangular block of characters, use&nbsp;<span class="Special">CTRL-V</span>&nbsp;to start<br>
Visual mode.&nbsp;&nbsp;This is very useful when working on tables.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Q1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Q2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Q3<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pierre&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;123&nbsp;&nbsp;&nbsp;&nbsp; 455&nbsp;&nbsp;&nbsp;&nbsp; 234<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;john&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 90&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;39<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;steve&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 392&nbsp;&nbsp;&nbsp;&nbsp; 63&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;334<br>
<br>
To delete the middle &quot;Q2&quot; column, move the cursor to the &quot;Q&quot; of &quot;Q2&quot;.&nbsp;&nbsp;Press<br>
<span class="Special">CTRL-V</span>&nbsp;to start blockwise Visual mode.&nbsp;&nbsp;Now move the cursor three lines down<br>
with &quot;3j&quot; and to the next word with &quot;w&quot;.&nbsp;&nbsp;You can see the first character of<br>
the last column is included.&nbsp;&nbsp;To exclude it, use &quot;h&quot;.&nbsp;&nbsp;Now press &quot;d&quot; and the<br>
middle column is gone.<br>
<br>
<br>
GOING TO THE OTHER SIDE<br>
<br>
If you have selected some text in Visual mode, and discover that you need to<br>
change the other end of the selection, use the &quot;o&quot; command (Hint: o for other<br>
end).&nbsp;&nbsp;The cursor will go to the other end, and you can move the cursor to<br>
change where the selection starts.&nbsp;&nbsp;Pressing &quot;o&quot; again brings you back to the<br>
other end.<br>
<br>
When using blockwise selection, you have four corners.&nbsp;&nbsp;&quot;o&quot; only takes you to<br>
one of the other corners, diagonally.&nbsp;&nbsp;Use &quot;O&quot; to move to the other corner in<br>
the same line.<br>
<br>
<span class="Todo">Note</span>&nbsp;that &quot;o&quot; and &quot;O&quot; in Visual mode work very differently from Normal mode,<br>
where they open a new line below or above the cursor.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_04.html#04.5" name="04.5">04.5</a>&nbsp;&nbsp;Moving text<br>
<br>
When you delete something with the &quot;d&quot;, &quot;x&quot;, or another command, the text is<br>
saved.&nbsp;&nbsp;You can paste it back by using the p command.&nbsp;&nbsp;(The Vim name for<br>
this is put).<br>
&nbsp;&nbsp; Take a look at how this works.&nbsp;&nbsp;First you will delete an entire line, by<br>
putting the cursor on the line you want to delete and typing &quot;dd&quot;.&nbsp;&nbsp;Now you<br>
move the cursor to where you want to put the line and use the &quot;p&quot; (put)<br>
command.&nbsp;&nbsp;The line is inserted on the line below the cursor.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a line&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a line&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a line<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;line 2&nbsp;&nbsp;&nbsp;&nbsp;dd&nbsp;&nbsp;&nbsp;&nbsp;line 3&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;&nbsp; line 3<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;line 3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;line 2<br>
<br>
Because you deleted an entire line, the &quot;p&quot; command placed the text line below<br>
the cursor.&nbsp;&nbsp;If you delete part of a line (a word, for instance), the &quot;p&quot;<br>
command puts it just after the cursor.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">Some more boring try text to out commands.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dw<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">Some more boring text to out commands.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -------&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;welp<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">Some more boring text to try out commands.</span><br>
<br>
<br>
MORE ON PUTTING<br>
<br>
The &quot;P&quot; command puts text like &quot;p&quot;, but before the cursor.&nbsp;&nbsp;When you deleted a<br>
whole line with &quot;dd&quot;, &quot;P&quot; will put it back above the cursor.&nbsp;&nbsp;When you deleted<br>
a word with &quot;dw&quot;, &quot;P&quot; will put it back just before the cursor.<br>
<br>
You can repeat putting as many times as you like.&nbsp;&nbsp;The same text will be used.<br>
<br>
You can use a count with &quot;p&quot; and &quot;P&quot;.&nbsp;&nbsp;The text will be repeated as many times<br>
as specified with the count.&nbsp;&nbsp;Thus &quot;dd&quot; and then &quot;3p&quot; puts three copies of the<br>
same deleted line.<br>
<br>
<br>
SWAPPING TWO CHARACTERS<br>
<br>
Frequently when you are typing, your fingers get ahead of your brain (or the<br>
other way around?).&nbsp;&nbsp;The result is a typo such as &quot;teh&quot; for &quot;the&quot;.&nbsp;&nbsp;Vim<br>
makes it easy to correct such problems.&nbsp;&nbsp;Just put the cursor on the e of &quot;teh&quot;<br>
and execute the command &quot;xp&quot;.&nbsp;&nbsp;This works as follows: &quot;x&quot; deletes the<br>
character e and places it in a register.&nbsp;&nbsp;&quot;p&quot; puts the text after the cursor,<br>
which is after the h.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">teh&nbsp;&nbsp;&nbsp;&nbsp; th&nbsp;&nbsp;&nbsp;&nbsp; the</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_04.html#04.6" name="04.6">04.6</a>&nbsp;&nbsp;Copying text<br>
<br>
To copy text from one place to another, you could delete it, use &quot;u&quot; to undo<br>
the deletion and then &quot;p&quot; to put it somewhere else.&nbsp;&nbsp;There is an easier way:<br>
yanking.&nbsp;&nbsp;The &quot;y&quot; operator copies text into a register.&nbsp;&nbsp;Then a &quot;p&quot; command<br>
can be used to put it.<br>
&nbsp;&nbsp; Yanking is just a Vim name for copying.&nbsp;&nbsp;The &quot;c&quot; letter was already used<br>
for the change operator, and &quot;y&quot; was still available.&nbsp;&nbsp;Calling this<br>
operator &quot;yank&quot; made it easier to remember to use the &quot;y&quot; key.<br>
<br>
Since &quot;y&quot; is an operator, you use &quot;yw&quot; to yank a word.&nbsp;&nbsp;A count is possible as<br>
usual.&nbsp;&nbsp;To yank two words use &quot;y2w&quot;.&nbsp;&nbsp;Example:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">let sqr = LongVariable *</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --------------&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; y2w<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">let sqr = LongVariable *</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; p<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">let sqr = LongVariable * LongVariable</span><br>
<br>
Notice that &quot;yw&quot; includes the white space after a word.&nbsp;&nbsp;If you don't want<br>
this, use &quot;ye&quot;.<br>
<br>
The &quot;yy&quot; command yanks a whole line, just like &quot;dd&quot; deletes a whole line.<br>
Unexpectedly, while &quot;D&quot; deletes from the cursor to the end of the line, &quot;Y&quot;<br>
works like &quot;yy&quot;, it yanks the whole line.&nbsp;&nbsp;Watch out for this inconsistency!<br>
Use &quot;y$&quot; to yank to the end of the line.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a text line&nbsp;&nbsp; yy&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a text line&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a text line<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;line 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;line 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;line 2<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;last line&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; last line&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a text line<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; last line<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_04.html#04.7" name="04.7">04.7</a>&nbsp;&nbsp;Using the clipboard<br>
<br>
If you are using the GUI version of Vim (gvim), you can find the &quot;Copy&quot; item<br>
in the &quot;Edit&quot; menu.&nbsp;&nbsp;First select some text with Visual mode, then use the<br>
Edit/Copy menu.&nbsp;&nbsp;The selected text is now copied to the clipboard.&nbsp;&nbsp;You can<br>
paste the text in other programs.&nbsp;&nbsp;In Vim itself too.<br>
<br>
If you have copied text to the clipboard in another application, you can paste<br>
it in Vim with the Edit/Paste menu.&nbsp;&nbsp;This works in Normal mode and Insert<br>
mode.&nbsp;&nbsp;In Visual mode the selected text is replaced with the pasted text.<br>
<br>
The &quot;Cut&quot; menu item deletes the text before it's put on the clipboard.&nbsp;&nbsp;The<br>
&quot;Copy&quot;, &quot;Cut&quot; and &quot;Paste&quot; items are also available in the popup menu (only<br>
when there is a popup menu, of course).&nbsp;&nbsp;If your Vim has a toolbar, you can<br>
also find these items there.<br>
<br>
If you are not using the GUI, or if you don't like using a menu, you have to<br>
use another way.&nbsp;&nbsp;You use the normal &quot;y&quot; (yank) and &quot;p&quot; (put) commands, but<br>
prepend &quot;* (double-quote star) before it.&nbsp;&nbsp;To copy a line to the clipboard:<br>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;*yy</div>
<br>
To put text from the clipboard back into the text:<br>
<br>
<div class="helpExample">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&quot;*p</div>
<br>
This only works on versions of Vim that include clipboard support.&nbsp;&nbsp;More about<br>
the clipboard in section&nbsp;<a class="Identifier" href="usr_09.html#09.3">09.3</a>&nbsp;and here:&nbsp;<a class="Identifier" href="gui.html#clipboard">clipboard</a>.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_04.html#04.8" name="04.8">04.8</a>&nbsp;&nbsp;Text objects<br>
<br>
If the cursor is in the middle of a word and you want to delete that word, you<br>
need to move back to its start before you can do &quot;dw&quot;.&nbsp;&nbsp;There is a simpler way<br>
to do this: &quot;daw&quot;.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">this is some example text.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; daw<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">this is some text.</span><br>
<br>
The &quot;d&quot; of &quot;daw&quot; is the delete operator.&nbsp;&nbsp;&quot;aw&quot; is a text object.&nbsp;&nbsp;Hint: &quot;aw&quot;<br>
stands for &quot;A Word&quot;.&nbsp;&nbsp;Thus &quot;daw&quot; is &quot;Delete A Word&quot;.&nbsp;&nbsp;To be precise, the white<br>
space after the word is also deleted (the white space before the word at the<br>
end of the line).<br>
<br>
Using text objects is the third way to make changes in Vim.&nbsp;&nbsp;We already had<br>
operator-motion and Visual mode.&nbsp;&nbsp;Now we add operator-text object.<br>
&nbsp;&nbsp; It is very similar to operator-motion, but instead of operating on the text<br>
between the cursor position before and after a movement command, the text<br>
object is used as a whole.&nbsp;&nbsp;It doesn't matter where in the object the cursor<br>
was.<br>
<br>
To change a whole sentence use &quot;cis&quot;.&nbsp;&nbsp;Take this text:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">Hello there.&nbsp;&nbsp;This</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">is an example.&nbsp;&nbsp;Just</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">some text.</span><br>
<br>
Move to the start of the second line, on &quot;is an&quot;.&nbsp;&nbsp;Now use &quot;cis&quot;:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">Hello there.&nbsp;&nbsp;&nbsp;&nbsp;Just</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">some text.</span><br>
<br>
The cursor is in between the blanks in the first line.&nbsp;&nbsp;Now you type the new<br>
sentence &quot;Another line.&quot;:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">Hello there.&nbsp;&nbsp;Another line.&nbsp;&nbsp;Just</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">some text.</span><br>
<br>
&quot;cis&quot; consists of the &quot;c&quot; (change) operator and the &quot;is&quot; text object.&nbsp;&nbsp;This<br>
stands for &quot;Inner Sentence&quot;.&nbsp;&nbsp;There is also the &quot;as&quot; (a sentence) object.&nbsp;&nbsp;The<br>
difference is that &quot;as&quot; includes the white space after the sentence and &quot;is&quot;<br>
doesn't.&nbsp;&nbsp;If you would delete a sentence, you want to delete the white space<br>
at the same time, thus use &quot;das&quot;.&nbsp;&nbsp;If you want to type new text the white<br>
space can remain, thus you use &quot;cis&quot;.<br>
<br>
You can also use text objects in Visual mode.&nbsp;&nbsp;It will include the text object<br>
in the Visual selection.&nbsp;&nbsp;Visual mode continues, thus you can do this several<br>
times.&nbsp;&nbsp;For example, start Visual mode with &quot;v&quot; and select a sentence with<br>
&quot;as&quot;.&nbsp;&nbsp;Now you can repeat &quot;as&quot; to include more sentences.&nbsp;&nbsp;Finally you use an<br>
operator to do something with the selected sentences.<br>
<br>
You can find a long list of text objects here:&nbsp;<a class="Identifier" href="motion.html#text-objects">text-objects</a>.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_04.html#04.9" name="04.9">04.9</a>&nbsp;&nbsp;Replace mode<br>
<br>
The &quot;R&quot; command causes Vim to enter replace mode.&nbsp;&nbsp;In this mode, each<br>
character you type replaces the one under the cursor.&nbsp;&nbsp;This continues until<br>
you type&nbsp;<span class="Special">&lt;Esc&gt;</span>.<br>
&nbsp;&nbsp; In this example you start Replace mode on the first &quot;t&quot; of &quot;text&quot;:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">This is text.</span><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Rinteresting.<span class="Special">&lt;Esc&gt;</span><br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="PreProc">This is interesting.</span><br>
<br>
You may have noticed that this command replaced 5 characters in the line with<br>
twelve others.&nbsp;&nbsp;The &quot;R&quot; command automatically extends the line if it runs out<br>
of characters to replace.&nbsp;&nbsp;It will not continue on the next line.<br>
<br>
You can switch between Insert mode and Replace mode with the&nbsp;<span class="Special">&lt;Insert&gt;</span>&nbsp;key.<br>
<br>
When you use&nbsp;<span class="Special">&lt;BS&gt;</span>&nbsp;(backspace) to make correction, you will notice that the<br>
old text is put back.&nbsp;&nbsp;Thus it works like an undo command for the last typed<br>
character.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<a class="Constant" href="usr_04.html#04.10" name="04.10">04.10</a>&nbsp;Conclusion<br>
<br>
The operators, movement commands and text objects give you the possibility to<br>
make lots of combinations.&nbsp;&nbsp;Now that you know how it works, you can use&nbsp;<span class="Special">N</span><br>
operators with M movement commands to make&nbsp;<span class="Special">N</span>&nbsp;* M commands!<br>
<br>
You can find a list of operators here:&nbsp;<a class="Identifier" href="motion.html#operator">operator</a><br>
<br>
For example, there are many other ways to delete pieces of text.&nbsp;&nbsp;Here are a<br>
few often used ones:<br>
<br>
x&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete character under the cursor (short for &quot;dl&quot;)<br>
X&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete character before the cursor (short for &quot;dh&quot;)<br>
D&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; delete from cursor to end of line (short for &quot;d$&quot;)<br>
dw&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delete from cursor to next start of word<br>
db&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delete from cursor to previous start of word<br>
diw&nbsp;&nbsp;&nbsp;&nbsp; delete word under the cursor (excluding white space)<br>
daw&nbsp;&nbsp;&nbsp;&nbsp; delete word under the cursor (including white space)<br>
dG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;delete until the end of the file<br>
dgg&nbsp;&nbsp;&nbsp;&nbsp; delete until the start of the file<br>
<br>
If you use &quot;c&quot; instead of &quot;d&quot; they become change commands.&nbsp;&nbsp;And with &quot;y&quot; you<br>
yank the text.&nbsp;&nbsp;And so forth.<br>
<br>
<br>
There are a few often used commands to make changes that didn't fit somewhere<br>
else:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;~&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; change case of the character under the cursor, and move the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cursor to the next character.&nbsp;&nbsp;This is not an operator (unless<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a class="Type" href="options.html#'tildeop'">'tildeop'</a>&nbsp;is set), thus you can't use it with a motion<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;command.&nbsp;&nbsp;It does work in Visual mode and changes case for<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;all the selected text then.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start Insert mode after moving the cursor to the first<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;non-blank in the line.<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Start Insert mode after moving the cursor to the end of the<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;line.<br>
<br>
<span class="PreProc">==============================================================================</span><br>
<br>
Next chapter:&nbsp;<a class="Identifier" href="usr_05.html">usr_05.txt</a>&nbsp;&nbsp;Set your settings<br>
<br>
Copyright: see&nbsp;<a class="Identifier" href="usr_01.html#manual-copyright">manual-copyright</a>&nbsp;&nbsp;vim:tw=78:ts=8:ft=help:norl:<br>
</div>
</article>
<footer>
<a href="#top">Return to the top</a> - <a href="index.html">Return to main</a>
<span class="EnglishJapaneseLink">
<span class="CurrentLanguage">English</span>
</span>
<br />
<div style="text-align:right;">
Hosted by <a href="https://github.com/vim-jp/vimdoc-en">vimdoc-en project</a><br />
If you met any problem, please report it to <a href="https://github.com/vim-jp/vimdoc-en/issues">issue</a>.<br />
</div>
</footer>
<!--<script src="js/check-referrer.js" type="text/javascript"></script>-->
</body>
</html>
<!-- vim:set ts=8 sts=2 sw=2 tw=0 et: -->
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hilarryxu/vimdoc.git
git@gitee.com:hilarryxu/vimdoc.git
hilarryxu
vimdoc
vimdoc
master

搜索帮助