《Vim实用技巧》的原文摘录

  • If you take my advice, you’ll throw away the Caps Lock key forever. You won ’t miss it, I promise. (查看原文)
    seflyer 1回复 2013-02-05 20:49:46
    —— 引自第30页
  • But if you ’re getting a feel for the Vim way, then this should raise alarm bells for you. (查看原文)
    seflyer 2013-02-05 21:24:16
    —— 引自第42页
  • Normal mode: * # : search current word (forward / backward) g* g# : search current word forward / backward without word delimiters gv : reselect last selection zz : redraw screen so that current is in the center gg : go to start of file g~, gu, gU : change cases S : cc C : c$ @ : repeat last Ex ; , : next / last find q: : open command window <C-^> : toggle between files :ls : list buffers :args 0 : to first character of real line g0 : to first character of display line ge : backward to end of previous word t{char} : forward to the character before the next occurrence of {char}. e.g., dt. d / content} : delete till the occurence of the searched content. search command is an "exclusive" motion, i.e., the {word searched} won't be deleted in this case ci" : replace ever... (查看原文)
    无脊椎 2013-04-12 05:50:55
    —— 引自第1页
  • 表801 分隔符文本对象 ---- 文本对象 选择区域 ================================================== a)或ab 一对圆括号 {parentheses} i)或ib 圆括号内部 (parentheses)内部 a}或aB 一对花括号{braces} i}或iB 花括号{braces}内部 a] 一对方括号 [brackets] i] 方括号[brackets]内部 a> 一对尖括号<angle brackets> i> 尖括号<brackets>内部 a' 一对单引号'single quotes' i' 单引号'single quotes'内部 a" 一对双引号 "double quotes" i" 双括号内部 a` 一对反引号 `backticks` i` 反引号`backticks`内部 at 一对XML标签 <xml>tags</xml> it XML标签内部 (查看原文)
    sgsheg 2014-08-20 13:22:34
    —— 引自第115页
  • 删除周边,修改内部 (查看原文)
    sgsheg 2014-08-21 13:16:13
    —— 引自第117页
  • For example, if we wanted to yank the current word into register a, we could run "ayiw. Or if we wanted to cut the current line into register b, we could run "bdd. Then we could paste the word from register a by typing "ap, or we could paste the line from register typing "bp. In addition to the Normal mode commands, Vim also provides Ex commands for delete, yank and put operations. We could cut the current line into register c by running `:delete C`, and then we could paste it below the current line with the `:put c` command. These may seem verbose in comparison with the Normal mode commands, but they're useful in combination with other Ex commands and in Vim scripts. For example, shows how `:yank` can be used with the `:global` command. For example, ""p, which is effectively equivalent ... (查看原文)
    sgsheg 2014-08-26 13:52:18
    —— 引自第146页
  • Vim的自动补全可以在插入模式下被触发。当此功能被调用的时, Vim会首先根据当前编辑会话所有缓冲区的内容建立一份补全列表,然后再检测光标左侧的字符,看能否找到单词的一部分。如果找到的话,会用这个未完成的单词对补全列表进行过滤,所有不是以它开头的内容都将被过滤掉!最终的补全列表都以菜单形式出现,供我们选择。 通过 <C -p> 与 <C -n>这两个组合键,我们不仅可以在插入模式下触发Vim自动补全,而且还可以用它们在补全列表中反向或正向选择。 (查看原文)
    sgsheg 2014-09-04 13:20:08
    —— 引自第262页
  • <C-p>与<C-n>命令均会调用普通关键字来自动补全。除此之外,还有其他自动补全的方式,所有这些命令均以组合键<C -x>来作为起始操作。 触发Vim自动补全的方法总结 (查看原文)
    sgsheg 2014-09-04 13:20:08
    —— 引自第262页
  • 可供弹出式菜单使用的命令 ===================================== 按键操作 作用 <C -n> 使用来自补全列表的下一个匹配项(next匹配项) <C -p> 使用来自补全列表的上一个匹配项(previous匹配项) <Down> 选择来自补全列表的下一个匹配项 <Up> 选择来自补全列表的上一个匹配项 <C -y> 确认使用当前选中的匹配项(yes) <C -e> 还原最早输入的文本(从自动补全中的exit) <C -h>与<BS> 从当前匹配项中删除一个字符 <C -l> 从当前匹配项中增加一个字符 {char} 中止自动补全并插入字符{char} 浏览补全列表,但不更改文档内容 当我们按下<Down>时,位于弹出式菜单中的下一项将被选中,但不会更改文档中的文本. 滚动补全列表的同时更新文文档内容 相对于<Down>键而言,<C -n>键不仅可以选择列表中的下一项,而且它会使用选中的单词来更新文档.这意味着我们不用`按下<C -r>来确认选中项,因为文档中的文本总是与弹出式菜单的选择项保持同步. 由于下列种种原因,我更倾向于使用<C -p>与<C -n>这两个组合键,而不是<Down>与<Up>. 放弃所有选择项 在我们调出自动补全菜单后,或许又更想把它关闭.这种情况下我们可以使用<C -e>来中止这次自动补全,其... (查看原文)
    sgsheg 2014-09-04 21:24:28
    —— 引自第264页
  • 1. 缓冲区列表 基于当前关键字的补全可以通过<C -x><C -n>来进行触发. 以下命令可以: `: ls! ` 可以查看当前vim会话所打开的所有文件. 2. 使用字典中的单词进行自动补全 运行`:set spell`来触发vim的拼写检查功能,一旦我们输入<C -x><C -k>命令,所有位于拼写字典中的单词都会变成补全建议项 3. 自动补全整行文本 <C -x><C -l> (查看原文)
    sgsheg 2014-09-05 13:45:42
    —— 引自第267页
  • 1. Vim总是维护着一个当前工作目录,这一做法与shell类似.在任何给定的时间点,我们可以通过`:pwd`(print working directory)命令获取该信息,还可以通过`:cd {path}` 命令随时切换工作目录.另外,Vim的文件名自动补全功能只相对于工作目录的路径进行扩展,而不是相对于当前编辑文件的路径,理解这一点很重要. 2. 全能补全是由Vim实现的`intellsense`功能.它将提供一份为光标所处的上下文量身定做的补全建议列表.全能补全功能可由`<C -x><C -o>`命令进行触发. (查看原文)
    sgsheg 2014-09-07 20:25:53
    —— 引自第271页
  • 就像画家只花一小部分时间涂色一样,程序员也只花一小部分时间编写代码。绝大多数时间用来思考、阅读,以及在代码中穿梭浏览。而且,当确实需要做修改时,谁说一定要切换到插入模式才行? (查看原文)
    trekshot 2014-10-30 14:37:00
    —— 引自第15页
  • Touch typing is more than just not looking at the keyboard; it means doing it by feel. When touch typists make an error, they know it even before their eyes process the information on the screen in front of them. They feel it in their fingers, like a misplaced step. (查看原文)
    OrangeCLK 2017-03-06 13:00:28
    —— 引自第28页
  • <C-h> Delete back one character (backspace) <C-w> Delete back one word <C-u> Delete back to start of line (查看原文)
    OrangeCLK 2017-03-06 13:03:12
    —— 引自第28页
  • 我的意思并不是说绝对不能在substitute命令的查找域中输入文本。例如,下面的substitute命令会把文件中每一行的换行符都替换为逗号,最终形成一行。 => :%s/\n/, 对珠地这种简单的命令,就没必要将它一分为二了。否则的话,非但得不到什么好处,反而有可能增加工作量。 (查看原文)
    stephansun 1回复 2018-12-16 17:37:56
    —— 引自第207页