<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>IDEA on Allens' Blog</title><link>https://allens.tech/categories/idea/</link><description>Recent content from Allens' Blog</description><generator>Hugo</generator><language>en-us</language><managingEditor>allens.leng@gmail.com (Allens)</managingEditor><webMaster>allens.leng@gmail.com (Allens)</webMaster><copyright>All articles on this blog are licensed under the BY-NC-SA license agreement unless otherwise stated. Please indicate the source when reprinting!</copyright><lastBuildDate>Fri, 24 Apr 2020 12:00:00 +0800</lastBuildDate><atom:link href="https://allens.tech/categories/idea/index.xml" rel="self" type="application/rss+xml"/><item><title>VIM 个人学习</title><link>https://allens.tech/post/202004241200/</link><pubDate>Fri, 24 Apr 2020 12:00:00 +0800</pubDate><author>allens.leng@gmail.com (Allens)</author><guid>https://allens.tech/post/202004241200/</guid><description>
<![CDATA[<h1>VIM 个人学习</h1><p>Author: Allens(allens.leng@gmail.com)</p>
        
          <h2 id="描述">
<a class="header-anchor" href="#%e6%8f%8f%e8%bf%b0"></a>
描述
</h2><p>听说很多大佬最后的归宿都是  <strong>VIM</strong>，作为一个有仪式感的男人，我觉得  <strong>VIM</strong> 目前能带给我的感觉就是编程的完整性，让你感觉敲得每一个字母都是在编程，哪怕是一个  <strong>o</strong>，而不是那种鼠标点点点的感觉，先说下我目前的使用方式吧，就是  <strong>GoLand</strong> 配合  <strong>VIM</strong> 插件开发，毕竟朋友说  <strong>VIM</strong> 学习成本太高，我目前确实没有过多的时间直接换编辑器</p>
<h2 id="编辑器选择">
<a class="header-anchor" href="#%e7%bc%96%e8%be%91%e5%99%a8%e9%80%89%e6%8b%a9"></a>
编辑器选择
</h2><p>作为一个比较能折腾的人来讲，我用过几款编辑器，包括  <strong>Notepad++</strong>， <strong>Sublime Text 3</strong>， <strong>VS Code</strong>， <strong>GoLand</strong>， <strong>Intellij IDEA</strong>，如果让我比较的话，站在我的角度：</p>
<ul>
<li><strong>Notepad++</strong> 我的使用深度不高，不评价;</li>
<li><strong>Sublime Text 3</strong> 要安装各种的插件去网上找文章，这对我这没啥事就重做个系统的人来讲，根本不能接受;</li>
<li><strong>VS Code</strong> 用了很久，扩展仓库不得不说，很好用，而且各种主题也符合我的审美，但是自从项目越来越大，保存文件要等 5 S 以上，就让我放弃了这个编辑器，因为真的很慢;</li>
<li><strong>GoLand</strong> 和  <strong>Intellij</strong> 没什么区别，都一样，只是买正版的话 GoLand 便宜一点;</li>
</ul>
<blockquote>
<p>上面的编辑器基本都有 VIM 的插件，装一下就可以了。</p>
</blockquote>
<h2 id="快捷键">
<a class="header-anchor" href="#%e5%bf%ab%e6%8d%b7%e9%94%ae"></a>
快捷键
</h2><p>网上起码有不下十篇文章称自己为最全的 <code>VIM</code> 快捷键，但其实一对比就会发现，总有几个需要的快捷键互相查漏补缺了，甚至还有一些快捷键解释都写错了，其实出于严谨性来说这种事情不应该发生的，如果我的文章有这种问题也欢迎大家和我<a href="mailto:allens.leng@gmail.com">邮件交流</a>，以下只记录一些自己常用的快捷键（逐渐补充）。</p>
<h3 id="光标位移">
<a class="header-anchor" href="#%e5%85%89%e6%a0%87%e4%bd%8d%e7%a7%bb"></a>
光标位移
</h3><ul>
<li><strong>h</strong> or  <strong>Backspace</strong>： 左移一个字符；</li>
<li><strong>l</strong> or  <strong>Space</strong>： 右移一个字符；</li>
<li><strong>k</strong>： 上移一行；</li>
<li><strong>j</strong>： 下移一行；</li>
<li><strong>b</strong>： 前移一个单词，光标停在上一个单词开头；</li>
<li><strong>B</strong>： 移动到上一个单词开头，忽略一些标点；</li>
<li><strong>w</strong>： 后移一个单词，光标停在下一个单词开头；</li>
<li><strong>W</strong>： 移动下一个单词开头，但忽略一些标点；</li>
<li><strong>e</strong>： 后移一个单词，光标停在下一个单词末尾；</li>
<li><strong>E</strong>： 移动到下一个单词末尾，如果词尾有标点，则移动到标点；</li>
<li><strong>(</strong>： 前移1句；</li>
<li><strong>)</strong>： 后移1句；</li>
<li><strong>{</strong>： 前移1段；</li>
<li><strong>}</strong>： 后移1段；</li>
<li><strong>fc</strong>： 把光标移到同一行的下一个c字符处；</li>
<li><strong>Fc</strong>： 把光标移到同一行的上一个c字符处；</li>
<li><strong>0</strong>： 移动到行首；</li>
<li><strong>$</strong>： 移动到行尾；</li>
<li><strong>^</strong>： 移动到本行第一个非空白字符；</li>
<li><strong>gg</strong>： 到文件头部；</li>
<li><strong>G</strong>： 到文件尾部；</li>
<li><strong>[ n ] G</strong>： 移动到  <strong>( n )</strong> 行的行首；</li>
</ul>
<h3 id="插入文本">
<a class="header-anchor" href="#%e6%8f%92%e5%85%a5%e6%96%87%e6%9c%ac"></a>
插入文本
</h3><ul>
<li><strong>i</strong>： 在光标前插入；[ 数字+i，进入插入模式，输入任意字符，按 Esc 进入命令模式，就会出现n个字符，这在插入分割线时非常有用，如30i+就插入了36个+组成的分割线。]</li>
<li><strong>I</strong>： 在当前行第一个非空字符前插入；</li>
<li><strong>gI</strong>： 在当前行第一列插入；</li>
<li><strong>a</strong>： 在光标后插入；</li>
<li><strong>A</strong>： 在当前行最后插入；</li>
<li><strong>o</strong>： 在下面新建一行插入；</li>
<li><strong>O</strong>： 在上面新建一行插入；</li>
</ul>
<h3 id="复制粘贴">
<a class="header-anchor" href="#%e5%a4%8d%e5%88%b6%e7%b2%98%e8%b4%b4"></a>
复制粘贴
</h3><h4 id="复制">
<a class="header-anchor" href="#%e5%a4%8d%e5%88%b6"></a>
复制
</h4><ul>
<li><strong>y</strong>： 复制在可视模式下选中的文本；</li>
<li><strong>y0</strong>： 从光标当前位置复制到行首；</li>
<li><strong>y$</strong>： 从光标当前位置复制到行尾；</li>
<li><strong>yG</strong>： 复制光标以下的所有行；</li>
<li><strong>y [ n ] w</strong>： 复制  <strong>( n )</strong> 个单词；</li>
<li><strong>yy</strong> or  <strong>Y</strong>： 复制整行文本；</li>
</ul>
<h4 id="剪切--删除">
<a class="header-anchor" href="#%e5%89%aa%e5%88%87--%e5%88%a0%e9%99%a4"></a>
剪切 &amp; 删除
</h4><ul>
<li><strong>d</strong>： 删除（剪切）在可视模式下选中的文本；</li>
<li><strong>d0</strong>： 删除（剪切）当前位置到行首的内容；</li>
<li><strong>d$</strong> or  <strong>D</strong>： 删除（剪切）当前位置到行尾的内容；</li>
<li><strong>dG</strong>： 删除（剪切）光标以下的所有行；</li>
<li><strong>d [ n ] w</strong>： 删除（剪切） <strong>( n )</strong> 个单词；</li>
<li><strong>[ n ] dd</strong>： 删除（剪切） <strong>( n )</strong> 行。</li>
</ul>
<h4 id="粘贴">
<a class="header-anchor" href="#%e7%b2%98%e8%b4%b4"></a>
粘贴
</h4><ul>
<li><strong>p</strong>： 在光标之后粘贴；</li>
<li><strong>P</strong>： 在光标之前粘贴；</li>
</ul>
<h3 id="查找">
<a class="header-anchor" href="#%e6%9f%a5%e6%89%be"></a>
查找
</h3><ul>
<li><strong>/ something</strong>： 在后面的文本中查找 something；</li>
<li><strong>? something</strong>： 在前面的文本中查找 something；</li>
<li><strong>n</strong>： 向后查找下一个；</li>
<li><strong>N</strong>： 向前查找下一个；</li>
</ul>
<h3 id="替换">
<a class="header-anchor" href="#%e6%9b%bf%e6%8d%a2"></a>
替换
</h3><ul>
<li><strong>:s/old/new</strong> - 用 new 替换当前行第一个 old；</li>
<li><strong>:s/old/new/g</strong> - 用 new 替换当前行所有的 old；</li>
<li><strong>:n1,n2s/old/new/g</strong> - 用 new 替换文件 n1 行到 n2 行所有的 old；</li>
<li><strong>:%s/old/new/g</strong> - 用 new 替换文件中所有的 old；</li>
<li><strong>:%s/^/xxx/g</strong> - 在每一行的行首插入 xxx，^ 表示行首；</li>
<li><strong>:%s/$/xxx/g</strong> - 在每一行的行尾插入 xxx，$ 表示行尾；</li>
</ul>
<blockquote>
<p>所有替换命令末尾加上 c，每个替换都将需要用户确认。 如：%s/old/new/gc，加上 i 则忽略大小写 ( ignore )；</p>
        
        <hr><p>Published on 2020-04-24 at <a href='https://allens.tech/'>Allens' Blog</a>, last modified on 2020-04-24</p>]]></description><category>IDEA</category></item></channel></rss>