1
0
wiki/Technology/GettingStarted/命令行工具/Vim/1.Vim-入门.html

1909 lines
546 KiB
HTML
Raw Normal View History

2024-09-06 10:58:26 +08:00
<!DOCTYPE html>
<html lang="zh"><head><title>Vim 快速入门</title><meta charset="utf-8"/><link rel="preconnect" href="https://fonts.googleapis.com"/><link rel="preconnect" href="https://fonts.gstatic.com"/><link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=IBM Plex Mono&amp;family=Noto Serif Simplified Chinese:wght@400;700&amp;family=Source Sans Pro:ital,wght@0,400;0,600;1,400;1,600&amp;display=swap"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta property="og:title" content="Vim 快速入门"/><meta property="og:description" content="Vim 是一个功能强大的文本编辑器,此文档提供了快速入门指南,包括基础操作、模式切换、文本编辑技巧等。."/><meta property="og:image" content="https://wiki.7wate.com/static/og-image.png"/><meta property="og:width" content="1200"/><meta property="og:height" content="675"/><link rel="icon" href="../../../../static/icon.png"/><meta name="description" content="Vim 是一个功能强大的文本编辑器,此文档提供了快速入门指南,包括基础操作、模式切换、文本编辑技巧等。."/><meta name="generator" content="Quartz"/><link href="../../../../index.css" rel="stylesheet" type="text/css" spa-preserve/><link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/katex.min.css" rel="stylesheet" type="text/css" spa-preserve/><script src="../../../../prescript.js" type="application/javascript" spa-preserve></script><script type="application/javascript" spa-preserve>const fetchData = fetch("../../../../static/contentIndex.json").then(data => data.json())</script></head><body data-slug="Technology/GettingStarted/命令行工具/Vim/1.Vim-入门"><div id="quartz-root" class="page"><div id="quartz-body"><div class="left sidebar"><h2 class="page-title"><a href="../../../..">🪴 X·Eden</a></h2><div class="spacer mobile-only"></div><div class="search"><button class="search-button" id="search-button"><p>搜索</p><svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19.9 19.7"><title>Search</title><g class="search-path" fill="none"><path stroke-linecap="square" d="M18.5 18.3l-5.4-5.4"></path><circle cx="8" cy="8" r="7"></circle></g></svg></button><div id="search-container"><div id="search-space"><input autocomplete="off" id="search-bar" name="search" type="text" aria-label="搜索些什么" placeholder="搜索些什么"/><div id="search-layout" data-preview="true"></div></div></div></div><button class="darkmode" id="darkmode"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="dayIcon" x="0px" y="0px" viewBox="0 0 35 35" style="enable-background:new 0 0 35 35" xml:space="preserve" aria-label="暗色模式"><title>暗色模式</title><path d="M6,17.5C6,16.672,5.328,16,4.5,16h-3C0.672,16,0,16.672,0,17.5 S0.672,19,1.5,19h3C5.328,19,6,18.328,6,17.5z M7.5,26c-0.414,0-0.789,0.168-1.061,0.439l-2,2C4.168,28.711,4,29.086,4,29.5 C4,30.328,4.671,31,5.5,31c0.414,0,0.789-0.168,1.06-0.44l2-2C8.832,28.289,9,27.914,9,27.5C9,26.672,8.329,26,7.5,26z M17.5,6 C18.329,6,19,5.328,19,4.5v-3C19,0.672,18.329,0,17.5,0S16,0.672,16,1.5v3C16,5.328,16.671,6,17.5,6z M27.5,9 c0.414,0,0.789-0.168,1.06-0.439l2-2C30.832,6.289,31,5.914,31,5.5C31,4.672,30.329,4,29.5,4c-0.414,0-0.789,0.168-1.061,0.44 l-2,2C26.168,6.711,26,7.086,26,7.5C26,8.328,26.671,9,27.5,9z M6.439,8.561C6.711,8.832,7.086,9,7.5,9C8.328,9,9,8.328,9,7.5 c0-0.414-0.168-0.789-0.439-1.061l-2-2C6.289,4.168,5.914,4,5.5,4C4.672,4,4,4.672,4,5.5c0,0.414,0.168,0.789,0.439,1.06 L6.439,8.561z M33.5,16h-3c-0.828,0-1.5,0.672-1.5,1.5s0.672,1.5,1.5,1.5h3c0.828,0,1.5-0.672,1.5-1.5S34.328,16,33.5,16z M28.561,26.439C28.289,26.168,27.914,26,27.5,26c-0.828,0-1.5,0.672-1.5,1.5c0,0.414,0.168,0.789,0.439,1.06l2,2 C28.711,30.832,29.086,31,29.5,31c0.828,0,1.5-0.672,1.5-1.5c0-0.414-0.168-0.789-0.439-1.061L28.561,26.439z M17.5,29 c-0.829,0-1.5,0.672-1.5,1.5v3c0,0.828,0.671,1.5,1.5,1.5s1.5-0.672,1.5-1.5v-3C19,29.672,18.329,29,17.5,29z M17.5,7 C11.71,7,7,11.71,7,17.5S11.71,28,17.5,28S28,23.29,28,17.5S23.29,
<h2 id="入门">入门<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#入门" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
<h3 id="运动图">运动图<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#运动图" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"></span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/▶ 光标 ▽/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">▷ 目标</span></span></code></pre></figure>
<h4 id="左右动作">左右动作<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#左右动作" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">╭┈┈┈┈┈┈┈┈┈┈┈┈┈ | </span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">├┈┈┈┈┈┈┈┈┈┈┈┈┈ </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> $ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">┆ ╭┈┈┈┈┈┈┈┈┈┈ ^ fe ┈┈┈┈┈┈┈┈╮ ┆</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">┆ ┆ ╭┈┈┈┈┈┈┈ Fo te ┈┈┈┈┈┈┈╮┆ ┆</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">┆ ┆ ┆╭┈┈┈┈┈┈ To </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">30</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">| ┈┈┈╮ ┆┆ ┆</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">┆ ┆ ┆┆ ╭┈┈┈┈ ge w ┈┈┈╮ ┆ ┆┆ ┆</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">┆ ┆ ┆┆ ┆ ╭┈┈ b e ┈╮ ┆ ┆ ┆┆ ┆</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">┆ ┆ ┆┆ ┆ ┆ ╭h l╮ ┆ ┆ ┆ ┆┆ ┆</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">▽ ▽ ▽▽ ▽ ▽ ▽▼ ▼▽ ▽ ▽ ▽ ▽▽ ▽</span></span>
<span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> &quot;A cheatsheet from quickReference&quot;</span></span></code></pre></figure>
<h4 id="上下动作">上下动作<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#上下动作" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> - </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">SCREEN </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> START</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ╭┈┬┈┈┈┈┈┈┈┈┈▷ </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#!</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/usr/</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">bin</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">/python</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ┆ ┆ ╭┈┈┈▷ </span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ┆ ┆ ┆ </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">print</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Hello&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ┆ ┆ { } ▶ </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">print</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Vim&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ┆ ┆ ┆ </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">print</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;!&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ┆ ┆ └┈▷ </span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> ┆ ┆ ╭┈┈┈┬┈┈┈▷ </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">print</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Welcome&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">G gg H M L k j ▶ </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">print</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;to&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">┆ ┆ └┈▷ </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">print</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Quick Reference&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">┆ ┆ </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">print</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;/vim&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">┆ ┆ </span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">┆ ╰┈┈┈┈┈▷ </span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"></span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> - </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">SCREEN </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> END</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈▷ </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">print</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;SCREEN 2&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span></span></code></pre></figure>
<h3 id="动作">动作<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#动作" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>h</code></td><td><code>j</code></td></tr><tr><td><code>&lt;C-u></code> <em>/</em> <code>&lt;C-d></code></td><td>上/下半页</td></tr><tr><td><code>&lt;C-b></code> <em>/</em> <code>&lt;C-f></code></td><td>向上/向下翻页</td></tr></tbody></table></div>
<h4 id="字-词">字 (词)<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#字-词" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>b</code> <em>/</em> <code>w</code></td><td>上一个/下一个单词</td></tr><tr><td><code>ge</code> <em>/</em> <code>e</code></td><td>上一个/下一个词尾</td></tr></tbody></table></div>
<h4 id="行"><a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#行" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>0</code> <em>(zero)</em> <em>/</em> <code>$</code></td><td>行的开始/结束</td></tr><tr><td><code>^</code></td><td>行开头 <em>(非空白)</em></td></tr></tbody></table></div>
<h4 id="字符串">字符串<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#字符串" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>Fe</code> <em>/</em> <code>fe</code></td><td>移动到上一个/下一个 <code>e</code></td></tr><tr><td><code>To</code> <em>/</em> <code>to</code></td><td>在上一个/下一个 <code>o</code> 之前/之后移动</td></tr><tr><td>`</td><td><code>*/*</code>n</td></tr></tbody></table></div>
<h4 id="文档">文档<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#文档" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>gg</code> <em>/</em> <code>G</code></td><td>第一行/最后一行</td></tr><tr><td><code>:n</code></td><td><code>nG</code></td></tr><tr><td><code>}</code> <em>/</em> <code>{</code></td><td>下一个/上一个空行</td></tr></tbody></table></div>
<h4 id="窗口">窗口<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#窗口" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>H</code> <em>/</em> <code>M</code> <em>/</em> <code>L</code></td><td>上/中/下屏幕</td></tr><tr><td><code>zt</code> <em>/</em> <code>zz</code> <em>/</em> <code>zb</code></td><td>上/中/下这条线</td></tr></tbody></table></div>
<h3 id="插入模式">插入模式<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#插入模式" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>i</code> <em>/</em> <code>a</code></td><td>在光标之前/之后插入</td></tr><tr><td><code>I</code> <em>/</em> <code>A</code></td><td>插入行的开始/结束</td></tr><tr><td><code>o</code> <em>/</em> <code>O</code> <em>(letter)</em></td><td>在下方/上方插入新行</td></tr><tr><td><code>s</code> <em>/</em> <code>S</code></td><td>删除字符/行并插入</td></tr><tr><td><code>C</code> <em>/</em> <code>cc</code></td><td>更改到/当前行的结尾</td></tr><tr><td><code>gi</code></td><td>在最后一个插入点插入</td></tr><tr><td><code>Esc</code></td><td><code>&lt;C-[></code></td></tr></tbody></table></div>
<h3 id="保存和退出">保存和退出<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#保存和退出" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>:w</code></td><td>保存</td></tr><tr><td><code>:q</code></td><td>关闭文件</td></tr><tr><td><code>:wq</code></td><td><code>:x</code></td></tr><tr><td><code>:wqa</code></td><td>保存并退出所有文件</td></tr><tr><td><code>:q!</code></td><td><code>ZQ</code></td></tr><tr><td><code>:qa</code></td><td>关闭所有文件</td></tr><tr><td><code>:qa!</code></td><td>强制退出所有文件</td></tr><tr><td><code>:w</code> new.txt</td><td>写入 <code>new.txt</code></td></tr><tr><td><code>:sav</code> new.txt</td><td>保存并编辑 <code>new.txt</code></td></tr><tr><td><code>:w</code> !sudo tee %</td><td>写入只读文件</td></tr></tbody></table></div>
<h3 id="正常模式">正常模式<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#正常模式" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>r</code></td><td>替换一个字符</td></tr><tr><td><code>R</code></td><td>进入替换模式</td></tr><tr><td><code>u</code> <em>/</em> <code>3u</code></td><td>撤消更改 <code>1</code>/<code>3</code></td></tr><tr><td><code>U</code></td><td>在一行上撤消更改</td></tr><tr><td><code>J</code></td><td>加入下一行</td></tr><tr><td><code>&lt;C-r></code> <em>/</em> 5 <code>&lt;C-r></code></td><td>重做更改 <code>1</code>/<code>5</code></td></tr></tbody></table></div>
<h3 id="剪切和粘贴">剪切和粘贴<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#剪切和粘贴" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>x</code></td><td>删除字符 <em>(剪切)</em></td></tr><tr><td><code>p</code> <em>/</em> <code>P</code></td><td>在之后/之前粘贴</td></tr><tr><td><code>xp</code></td><td>交换两个字符</td></tr><tr><td><code>D</code></td><td>删除到行尾 <em>(剪切)</em></td></tr><tr><td><code>dw</code></td><td>删除单词 <em>(剪切)</em></td></tr><tr><td><code>dd</code></td><td>删除线 <em>(剪切)</em></td></tr><tr><td><code>ddp</code></td><td>交换两条线</td></tr><tr><td><code>yy</code></td><td>拉线 <em>(复制)</em></td></tr><tr><td><code>&quot;*p</code></td><td><code>&quot;+p</code></td></tr><tr><td><code>&quot;*y</code></td><td><code>&quot;+y</code></td></tr></tbody></table></div>
<h4 id="在可视化模式下">在可视化模式下<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#在可视化模式下" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>d</code> *</td><td>* <code>x</code></td></tr><tr><td><code>s</code></td><td>替换选择</td></tr><tr><td><code>y</code></td><td>Yank 选择 <em>(复制)</em></td></tr></tbody></table></div>
<h3 id="重复">重复<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#重复" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>.</code></td><td>重复上一个命令</td></tr><tr><td><code>;</code></td><td>重复最新的 <code>f</code><code>t</code><code>F</code><code>T</code></td></tr><tr><td><code>,</code></td><td>重复最新的 <code>f</code><code>t</code><code>F</code><code>T</code> 颠倒</td></tr><tr><td><code>&amp;</code></td><td>重复最后一个 <code>:s</code></td></tr><tr><td><code>@:</code></td><td>重复命令行命令</td></tr></tbody></table></div>
<h3 id="可视化模式">可视化模式<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#可视化模式" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>v</code></td><td>进入可视化模式</td></tr><tr><td><code>V</code></td><td>进入视线模式</td></tr><tr><td><code>&lt;C-v></code></td><td>进入可视化阻挡模式</td></tr><tr><td><code>ggVG</code></td><td>选择所有文本</td></tr><tr><td><code>></code> <em>/</em> <code>&lt;</code></td><td>向右/向左移动文本</td></tr></tbody></table></div>
<h3 id="宏"><a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#宏" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>qi</code></td><td>录制宏 <code>i</code></td></tr><tr><td><code>q</code></td><td>停止录制宏</td></tr><tr><td><code>@i</code></td><td>运行宏 <code>i</code></td></tr><tr><td><code>7@i</code></td><td>运行宏 <code>i</code> 7 次</td></tr><tr><td><code>@@</code></td><td>重复上一个宏</td></tr></tbody></table></div>
<p>您可以为任何字母保存宏,而不仅仅是 <code>i</code></p>
<h2 id="vim-运算符">Vim 运算符<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#vim-运算符" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
<h3 id="用法">用法<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#用法" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>d</code></td><td>w</td></tr><tr><td>运算符</td><td>动作</td></tr></tbody></table></div>
<p><a href="https://github.com/jaywcjlove/reference/blob/main/docs/vim.md#%E5%8F%AF%E7%94%A8%E8%BF%90%E7%AE%97%E7%AC%A6" class="external">可用运算符<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a><a href="https://github.com/jaywcjlove/reference/blob/main/docs/vim.md#%E5%8A%A8%E4%BD%9C" class="external">动作<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a> 结合使用以使用它们</p>
<h3 id="可用运算符">可用运算符<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#可用运算符" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>d</code></td><td>删除</td></tr><tr><td><code>y</code></td><td>Yank <em>(复制)</em></td></tr><tr><td><code>c</code></td><td>更改 <em>(删除然后插入)</em></td></tr><tr><td><code>p</code></td><td>粘贴</td></tr><tr><td><code>=</code></td><td>格式代码</td></tr><tr><td><code>g~</code></td><td>切换案例</td></tr><tr><td><code>gU</code></td><td>大写</td></tr><tr><td><code>gu</code></td><td>小写</td></tr><tr><td><code>></code></td><td>右缩进</td></tr><tr><td><code>&lt;</code></td><td>左缩进</td></tr><tr><td><code>!</code></td><td>通过外部程序过滤</td></tr></tbody></table></div>
<h3 id="例子">例子<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#例子" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>组合</th><th>说明</th></tr></thead><tbody><tr><td><code>d</code>d</td><td>删除当前行</td></tr><tr><td><code>d</code>j</td><td>删除两行</td></tr><tr><td><code>d</code>w</td><td>删除到下一个单词</td></tr><tr><td><code>d</code>b</td><td>删除到单词的开头</td></tr><tr><td><code>d</code>fa</td><td>删除直到 <code>a</code> 字符</td></tr><tr><td><code>d</code>/hello</td><td>删除直到 <code>hello</code></td></tr><tr><td><code>c</code>c</td><td>更改当前行,与 <code>S</code> 同义</td></tr><tr><td><code>y</code>y</td><td>复制当前行</td></tr><tr><td><code>></code>j</td><td>缩进 2 行</td></tr><tr><td>gg<code>d</code>G</td><td>删除完整的文档</td></tr><tr><td>gg<code>=</code>G</td><td>缩进一个完整的文档</td></tr><tr><td>gg<code>y</code>G</td><td>复制整个文档</td></tr></tbody></table></div>
<h3 id="计数">计数<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#计数" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[数字] &lt;运算符> &lt;动作></span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&lt;运算符> [数字] &lt;动作></span></span></code></pre></figure>
<hr/>
<div class="table-container"><table><thead><tr><th>组合</th><th>说明</th></tr></thead><tbody><tr><td>2<code>d</code>d</td><td>删除 <code>2</code></td></tr><tr><td>6<code>y</code>y</td><td>复制 <code>6</code></td></tr><tr><td><code>d</code>3w</td><td>删除 <code>3</code></td></tr><tr><td><code>d</code>5j</td><td>向下删除 <code>5</code></td></tr><tr><td><code>></code>4k</td><td>向上缩进 <code>4</code></td></tr></tbody></table></div>
<h2 id="vim-文本对象">Vim 文本对象<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#vim-文本对象" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
<h3 id="用法-1">用法<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#用法-1" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>v</code></td><td>i <em>/</em> a</td></tr><tr><td>Operator</td><td>inner(内部) <em>/</em> around(周围)</td></tr></tbody></table></div>
<p>文本块内部或周围使用 <a href="https://github.com/jaywcjlove/reference/blob/main/docs/vim.md#%E5%8F%AF%E7%94%A8%E8%BF%90%E7%AE%97%E7%AC%A6" class="external">operator<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a> 进行操作</p>
<h3 id="文本对象">文本对象<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#文本对象" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td>p</td><td>段落</td></tr><tr><td>w</td><td>单词</td></tr><tr><td>W</td><td>WORD <em>(被空格包围)</em></td></tr><tr><td>s</td><td>句子</td></tr><tr><td>[ ( { &lt;</td><td>[]、() 或 {} 块</td></tr><tr><td>] ) } ></td><td>[]、() 或 {} 块</td></tr><tr><td> ” `</td><td>带引号的字符串</td></tr><tr><td>b</td><td>一个块 [(</td></tr><tr><td>B</td><td>[{中的一个块</td></tr><tr><td>t</td><td>一个 HTML 标签块</td></tr></tbody></table></div>
<p>查看 <code>:help text-objects</code></p>
<h3 id="删除">删除<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#删除" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>d</code>iw</td><td>删除内词</td></tr><tr><td><code>d</code>is</td><td>删除内句</td></tr><tr><td><code>d</code>i”</td><td>引号中删除</td></tr><tr><td><code>d</code>a”</td><td>删除引号 <em>(包括引号)</em></td></tr><tr><td><code>d</code>ip</td><td>删除段落</td></tr></tbody></table></div>
<h3 id="选择">选择<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#选择" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>v</code>i”</td><td>选择内引号“<code>...</code>{.underline}”</td></tr><tr><td><code>v</code>a”</td><td>选择引号 <code>&quot;...&quot;</code>{.underline}</td></tr><tr><td><code>v</code>i[</td><td>选择内括号 [<code>...</code>{.underline}]</td></tr><tr><td><code>v</code>a[</td><td>选择括号 <code>[...]</code>{.underline}</td></tr><tr><td><code>v</code>iw</td><td>选择内词</td></tr><tr><td><code>v</code>ip</td><td>选择内部段落</td></tr><tr><td><code>v</code>ipip</td><td>选择更多段落</td></tr></tbody></table></div>
<h3 id="杂项">杂项<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#杂项" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>c</code>iw</td><td>换内字</td></tr><tr><td><code>c</code>i”</td><td>更改内部引号</td></tr><tr><td><code>c</code>it</td><td>更改内部标签 (HTML)</td></tr><tr><td><code>c</code>ip</td><td>更改内部段落</td></tr><tr><td><code>y</code>ip</td><td>Yank 段落</td></tr><tr><td><code>y</code>ap</td><td>Yank 段落 <em>(包括换行符)</em></td></tr></tbody></table></div>
<h2 id="vim-多个文件">Vim 多个文件<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#vim-多个文件" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
<h3 id="buffers-缓冲器">Buffers (缓冲器)<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#buffers-缓冲器" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>:e file</code></td><td>在新缓冲区中编辑文件</td></tr><tr><td><code>:bn</code></td><td>转到下一个缓冲区</td></tr><tr><td><code>:bp</code></td><td>转到上一个缓冲区</td></tr><tr><td><code>:bd</code></td><td>从缓冲区列表中删除文件</td></tr><tr><td><code>:b 5</code></td><td>打开缓冲区 #5</td></tr><tr><td><code>:b file</code></td><td>按文件转到缓冲区</td></tr><tr><td><code>:ls</code></td><td>列出所有打开的缓冲区</td></tr><tr><td><code>:sp file</code></td><td>打开和拆分窗口</td></tr><tr><td><code>:vs file</code></td><td>打开和垂直拆分窗口</td></tr><tr><td><code>:hid</code></td><td>隐藏此缓冲区</td></tr><tr><td><code>:wn</code></td><td>写入文件并移至下一个</td></tr><tr><td><code>:tab ba</code></td><td>将所有缓冲区编辑为选项卡</td></tr></tbody></table></div>
<h3 id="窗口-1">窗口<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#窗口-1" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>&lt;C-w></code> <code>s</code></td><td>拆分窗口</td></tr><tr><td><code>&lt;C-w></code> <code>v</code></td><td>垂直拆分窗口</td></tr><tr><td><code>&lt;C-w></code> <code>w</code></td><td>切换窗口</td></tr><tr><td><code>&lt;C-w></code> <code>q</code></td><td>退出一个窗口</td></tr><tr><td><code>&lt;C-w></code> <code>T</code></td><td>拆分成一个新标签</td></tr><tr><td><code>&lt;C-w></code> <code>x</code></td><td>用下一个交换当前</td></tr><tr><td><code>&lt;C-w></code> <code>-</code> <em>/</em> <code>+</code></td><td>减少/增加高度</td></tr><tr><td><code>&lt;C-w></code> <code>&lt;</code> <em>/</em> <code>></code></td><td>减少/增加宽度</td></tr><tr><td><code>&lt;C-w></code> `</td><td>`</td></tr><tr><td><code>&lt;C-w></code> <code>=</code></td><td>同样高和宽</td></tr><tr><td><code>&lt;C-w></code> <code>h</code> <em>/</em> <code>l</code></td><td>转到左/右窗口</td></tr><tr><td><code>&lt;C-w></code> <code>j</code> <em>/</em> <code>k</code></td><td>转到上/下窗口</td></tr></tbody></table></div>
<h3 id="选项卡">选项卡<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#选项卡" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>:tabe [file]</code></td><td>E 在新选项卡中编辑文件</td></tr><tr><td><code>:tabf [file]</code></td><td>如果在新选项卡中存在则打开</td></tr><tr><td><code>:tabc</code></td><td>C 失去当前选项卡</td></tr><tr><td><code>:tabo</code></td><td>关闭 o 其他选项卡</td></tr><tr><td><code>:tabs</code></td><td>列出所有标签</td></tr><tr><td><code>:tabr</code></td><td>转到第一个 r 标签</td></tr><tr><td><code>:tabl</code></td><td>转到 last 选项卡</td></tr><tr><td><code>:tabm 0</code></td><td>我转到位置 <code>0</code></td></tr><tr><td><code>:tabn</code></td><td>转到 next 选项卡</td></tr><tr><td><code>:tabp</code></td><td>转到 p 上一个标签</td></tr></tbody></table></div>
<h4 id="正常模式-1">正常模式<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#正常模式-1" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h4>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>gt</code></td><td>转到 next 选项卡</td></tr><tr><td><code>gT</code></td><td>转到 p 上一个标签</td></tr><tr><td><code>2gt</code></td><td>转到标签编号 <code>2</code></td></tr></tbody></table></div>
<h2 id="vim-搜索和替换">Vim 搜索和替换<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#vim-搜索和替换" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
<h3 id="搜索">搜索<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#搜索" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>/foo</code></td><td>向前搜索</td></tr><tr><td><code>/foo\c</code></td><td>向前搜索 <em>(不区分大小写)</em></td></tr><tr><td><code>?foo</code></td><td>向后搜索</td></tr><tr><td><code>/\v\d+</code></td><td>使用 <a href="https://github.com/jaywcjlove/reference/blob/main/docs/regex.md" class="external">regex<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a> 搜索</td></tr><tr><td><code>n</code></td><td>下一个匹配的搜索模式</td></tr><tr><td><code>N</code></td><td>上一个匹配的搜索</td></tr><tr><td><code>*</code></td><td>向前搜索当前单词</td></tr><tr><td><code>#</code></td><td>向后搜索当前单词</td></tr></tbody></table></div>
<h3 id="更换行">更换行<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#更换行" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:[</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">range</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/{pattern}/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{str}/[flags]</span></span></code></pre></figure>
<hr/>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>:s/old/new</code></td><td>先更换</td></tr><tr><td><code>:s/old/new/g</code></td><td>全部替换</td></tr><tr><td><code>:s/\vold/new/g</code></td><td>全部替换为 <a href="https://github.com/jaywcjlove/reference/blob/main/docs/regex.md" class="external">regex<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a></td></tr><tr><td><code>:s/old/new/gc</code></td><td>全部替换 <em>(确认)</em></td></tr><tr><td><code>:s/old/new/i</code></td><td>先忽略大小写替换</td></tr><tr><td><code>:2,6s/old/new/g</code></td><td><code>2</code>-<code>6</code> 行之间替换</td></tr></tbody></table></div>
<h3 id="替换文件">替换文件<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#替换文件" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:%s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/{pattern}/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">{str}/[flags]</span></span></code></pre></figure>
<hr/>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>:%s/old/new</code></td><td>先更换</td></tr><tr><td><code>:%s/old/new/g</code></td><td>全部替换</td></tr><tr><td><code>:%s/old/new/gc</code></td><td>全部替换 <em>(确认)</em></td></tr><tr><td><code>:%s/old/new/gi</code></td><td>全部替换 <em>(忽略大小写)</em></td></tr><tr><td><code>:%s/\vold/new/g</code></td><td>全部替换为 <a href="https://github.com/jaywcjlove/reference/blob/main/docs/regex.md" class="external">regex<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a></td></tr></tbody></table></div>
<h3 id="范围">范围<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#范围" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>%</code></td><td>整个文件</td></tr><tr><td><code>&lt;,></code></td><td>当前选择</td></tr><tr><td><code>5</code></td><td><code>5</code></td></tr><tr><td><code>5,10</code></td><td><code>5</code> 行到第 <code>10</code></td></tr><tr><td><code>$</code></td><td>最后一行</td></tr><tr><td><code>2,$</code></td><td><code>2</code> 行到最后</td></tr><tr><td><code>.</code></td><td>当前行</td></tr><tr><td><code>,3</code></td><td>接下来的 <code>3</code></td></tr><tr><td><code>-3,</code></td><td>转发 <code>3</code></td></tr></tbody></table></div>
<h3 id="全局命令">全局命令<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#全局命令" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:[</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">range</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]g</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/{pattern}/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span></code></pre></figure>
<hr/>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>:g/foo/d</code></td><td>删除包含 <code>foo</code> 的行</td></tr><tr><td><code>:g!/foo/d</code></td><td>删除不包含 <code>foo</code> 的行</td></tr><tr><td><code>:g/^\s*$/d</code></td><td>删除所有空行</td></tr><tr><td><code>:g/foo/t$</code></td><td>将包含 <code>foo</code> 的行复制到 EOF</td></tr><tr><td><code>:g/foo/m$</code></td><td>将包含 <code>foo</code> 的行移动到 EOF</td></tr><tr><td><code>:g/^/m0</code></td><td>反转文件</td></tr><tr><td><code>:g/^/t.</code></td><td>复制每一行</td></tr></tbody></table></div>
<h3 id="inverse逆-g">Inverse(逆) :g<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#inverse逆-g" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:[</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">range</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]v</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/{pattern}/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">[</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">command</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]</span></span></code></pre></figure>
<hr/>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>:v/foo/d</code></td><td>删除不包含 <code>foo</code> 的行 <em>(还有 <code>:g!/foo/d</code>)</em></td></tr></tbody></table></div>
<h3 id="flags标志">Flags(标志)<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#flags标志" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>g</code></td><td>替换所有出现</td></tr><tr><td><code>i</code></td><td>忽略大小写</td></tr><tr><td><code>I</code></td><td>不要忽略大小写</td></tr><tr><td><code>c</code></td><td>确认每个替换</td></tr></tbody></table></div>
<h3 id="替换表达式魔术">替换表达式(魔术)<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#替换表达式魔术" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>&amp;</code> *</td><td>* <code>\0</code></td></tr><tr><td><code>\1</code><code>\9</code></td><td>替换为 0-9 组</td></tr><tr><td><code>\u</code></td><td>大写下一个字母</td></tr><tr><td><code>\U</code></td><td>后面的大写字符</td></tr><tr><td><code>\l</code></td><td>小写下一个字母</td></tr><tr><td><code>\L</code></td><td>后面的字符小写</td></tr><tr><td><code>\e</code></td><td><code>\u</code><code>\U</code><code>\l</code><code>\L</code> 的结尾</td></tr><tr><td><code>\E</code></td><td><code>\u</code><code>\U</code><code>\l</code><code>\L</code> 的结尾</td></tr></tbody></table></div>
<h3 id="例子-1">例子<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#例子-1" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/a\|b/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">xxx</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">0xxx/g </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;a b&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 修改为 </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;xxxaxxx xxxbxxx&quot;</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/test/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">U&amp; file/ </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;test&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 修改为 </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;TEST FILE&quot;</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/\(test\)/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">U</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">e file/ </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;test&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 修改为 </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;TEST file&quot;</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/\v([abc])([efg])/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">/g </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;af fa bg&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 修改为 </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;fa fa gb&quot;</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/\v\w+/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">u</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">/g </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;bla bla&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 修改为 </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;Bla Bla&quot;</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/\v([ab])|([cd])/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">1x/g </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;a b c d&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 修改为 </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;ax bx x x&quot;</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:%s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/.*/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">L&amp;/ </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;HTML&quot;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 修改为 </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">&quot;html&quot;</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/\v&lt;(.)(\w*)/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">u</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">L</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">2</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">/g </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 将单词的每个首字母大写</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:%s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/^\(.*\)\n\1/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">/ </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 删除重复行</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:%s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/&lt;\/\=\(\w\+\)\>/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">U&amp;/g </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 将 HTML 标记转换为大写</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:g</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/^pattern/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">s</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/$/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">mytext </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 查找文本并将其附加到末尾</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:g</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/pattern/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">norm</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">!</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> @i </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 在匹配行上运行宏</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">/^</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(.*</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">r</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\?\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">n</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$ </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 查看重复行</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">v^(.*)(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">r</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">?\</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">n</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">\</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">)</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">$ </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 查看重复行(非常神奇)</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:v</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/./</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/./</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">-j </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 将空行压缩成空行</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:g</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/&lt;p1>/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">,</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF;">/&lt;p2>/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">d </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">&lt;p1> 到 &lt;p2> 包含删除</span></span></code></pre></figure>
<h2 id="vimdiff">Vimdiff<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#vimdiff" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
<h3 id="用法-2">用法<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#用法-2" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">vimdiff file1 file2 [file3]</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">vim -d file1 file2 [file3]</span></span></code></pre></figure>
<h3 id="编辑">编辑<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#编辑" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:[</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">range</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]diffget [bufspec]</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:[</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">range</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">]diffput [bufspec]</span></span></code></pre></figure>
<hr/>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>do</code> <em>/</em> <code>:diffget</code></td><td>获取get差异</td></tr><tr><td><code>dp</code> <em>/</em> <code>:diffput</code></td><td>放差价</td></tr><tr><td><code>:dif</code></td><td>重新扫描差异</td></tr><tr><td><code>:diffo</code></td><td>关闭差异模式</td></tr><tr><td><code>:1,$+1diffget</code></td><td>获取所有差异</td></tr><tr><td><code>ZQ</code></td><td>不做改动就退出</td></tr></tbody></table></div>
<p>请参阅:<a href="https://github.com/jaywcjlove/reference/blob/main/docs/vim.md#%E8%8C%83%E5%9B%B4" class="external">范围<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a></p>
<h3 id="折叠">折叠<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#折叠" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>zo</code> <em>/</em> <code>zO</code></td><td>打开</td></tr><tr><td><code>zc</code> <em>/</em> <code>zC</code></td><td></td></tr><tr><td><code>za</code> <em>/</em> <code>zA</code></td><td>切换</td></tr><tr><td><code>zv</code></td><td>这条线的打开折叠</td></tr><tr><td><code>zM</code></td><td>关闭所有</td></tr><tr><td><code>zR</code></td><td>打开所有</td></tr><tr><td><code>zm</code></td><td>折叠更多 <em>(折叠级别 += 1)</em></td></tr><tr><td><code>zr</code></td><td>少折叠 <em>(折叠级别 -= 1)</em></td></tr><tr><td><code>zx</code></td><td>更新折叠</td></tr></tbody></table></div>
<h3 id="跳跃">跳跃<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#跳跃" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>]c</code></td><td>下一个区别</td></tr><tr><td><code>[c</code></td><td>以前的区别</td></tr></tbody></table></div>
<h2 id="各种各样的">各种各样的<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#各种各样的" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
<h3 id="case">Case<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#case" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>vU</code></td><td><em>大写</em> 字母</td></tr><tr><td><code>vu</code></td><td><em>小写</em> 字符</td></tr><tr><td><code>~</code></td><td><em>切换案例</em> 字符</td></tr><tr><td><code>viw</code> <code>U</code></td><td><em>大写</em></td></tr><tr><td><code>viw</code> <code>u</code></td><td><em>小写</em></td></tr><tr><td><code>viw</code> <code>~</code></td><td><em>切换案例</em></td></tr><tr><td><code>VU</code> <em>/</em> <code>gUU</code></td><td><em>大写</em></td></tr><tr><td><code>Vu</code> <em>/</em> <code>guu</code></td><td><em>小写</em></td></tr><tr><td><code>V~</code> <em>/</em> <code>g~~</code></td><td><em>切换案例</em> 线</td></tr><tr><td><code>gggUG</code></td><td><em>大写</em> 所有文本</td></tr><tr><td><code>ggguG</code></td><td><em>小写</em> 所有文本</td></tr><tr><td><code>ggg~G</code></td><td><em>切换大小写</em> 所有文本</td></tr></tbody></table></div>
<h3 id="跳跃-1">跳跃<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#跳跃-1" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>&lt;C-o></code></td><td>返回上一个</td></tr><tr><td><code>&lt;C-i></code></td><td>向前</td></tr><tr><td><code>gf</code></td><td>转到光标中的文件</td></tr><tr><td><code>ga</code></td><td>显示十六进制、ASCII 值</td></tr></tbody></table></div>
<h3 id="其他命令行">其他命令行<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#其他命令行" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>:h</code></td><td>帮助打开帮助视图</td></tr><tr><td><code>:edit!</code></td><td>重新加载当前文件</td></tr><tr><td><code>:2,8m0</code></td><td>将行 <code>2</code>-<code>8</code> 移动到 <code>0</code></td></tr><tr><td><code>:noh</code></td><td>清除搜索亮点</td></tr><tr><td><code>:sort</code></td><td>排序行</td></tr><tr><td><code>:ter</code></td><td>打开终端窗口</td></tr><tr><td><code>:set paste</code></td><td>启用插入粘贴子模式</td></tr><tr><td><code>:set nopaste</code></td><td>禁用插入粘贴子模式</td></tr><tr><td><code>:cq</code></td><td>退出并出现错误 <em>(正在中止 Git)</em></td></tr></tbody></table></div>
<h3 id="导航">导航<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#导航" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>%</code></td><td>最近/匹配的 <code>{[()]}</code></td></tr><tr><td><code>[(</code> *</td><td>* <code>[{</code></td></tr><tr><td><code>])</code> *</td><td>* <code>]{</code></td></tr><tr><td><code>[m</code></td><td>上一个方法开始</td></tr><tr><td><code>[M</code></td><td>上一个方法结束</td></tr></tbody></table></div>
<h3 id="计数器">计数器<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#计数器" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>&lt;C-a></code></td><td>增加数量</td></tr><tr><td><code>&lt;C-x></code></td><td>减少数量</td></tr></tbody></table></div>
<h3 id="选项卡-1">选项卡<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#选项卡-1" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>:tag Classname</code></td><td>跳转到 Classname 的第一个定义</td></tr><tr><td><code>&lt;C-]></code></td><td>跳转到定义</td></tr><tr><td><code>g]</code></td><td>查看所有定义</td></tr><tr><td><code>&lt;C-t></code></td><td>回到最后一个标签</td></tr><tr><td><code>&lt;C-o> &lt;C-i></code></td><td>后退前进</td></tr><tr><td><code>:tselect Classname</code></td><td>查找类名的定义</td></tr><tr><td><code>:tjump Classname</code></td><td>查找类名的定义 <em>(自动选择第一个)</em></td></tr></tbody></table></div>
<h3 id="格式化">格式化<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#格式化" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>:ce 8</code></td><td><code>8</code> 列之间的中心线</td></tr><tr><td><code>:ri 4</code></td><td><code>4</code> 列右对齐行</td></tr><tr><td><code>:le</code></td><td>左对齐线</td></tr></tbody></table></div>
<p>查看 <code>:help formatting</code></p>
<h3 id="标记">标记<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#标记" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td>“^`</td><td>插入模式下光标的最后位置</td></tr><tr><td>“.`</td><td>当前缓冲区的最后更改</td></tr><tr><td>““`</td><td>最后退出的当前缓冲区</td></tr><tr><td>“0`</td><td>在上次编辑的文件中</td></tr><tr><td><code>''</code></td><td>返回当前缓冲区中跳出的行</td></tr><tr><td>````</td><td>返回当前缓冲区中跳转的位置</td></tr><tr><td>“[`</td><td>到先前更改或拉出的文本的开头</td></tr><tr><td>“]`</td><td>到之前更改或拉出的文本的结尾</td></tr><tr><td>&lt;`</td><td>到最后一个可视化选择的开始</td></tr><tr><td>“>`</td><td>到最后一个可视化选择的结尾</td></tr><tr><td><code>ma</code></td><td>将此光标位置标记为<code>a</code></td></tr><tr><td>“a`</td><td>跳转到光标位置 <code>a</code></td></tr><tr><td><code>'a</code></td><td>跳转到位置为 <code>a</code> 的行首</td></tr><tr><td><code>d'a</code></td><td>从当前行删除到标记 <code>a</code> 的行</td></tr><tr><td><code>d</code>a`</td><td>从当前位置删除到标记 <code>a</code> 的位置</td></tr><tr><td><code>c'a</code></td><td>将文本从当前行更改为 <code>a</code></td></tr><tr><td><code>y</code>a`</td><td>将文本从当前位置拉到 <code>a</code> 的位置</td></tr><tr><td><code>:marks</code></td><td>列出所有当前标记</td></tr><tr><td><code>:delm a</code></td><td>删除标记 <code>a</code></td></tr><tr><td><code>:delm a-d</code></td><td>删除标记 <code>a</code><code>b</code><code>c</code><code>d</code></td></tr><tr><td><code>:delm abc</code></td><td>删除标记 <code>a</code><code>b</code><code>c</code></td></tr></tbody></table></div>
<h3 id="计算器">计算器<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#计算器" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>&lt;C-r></code> <code>=</code> 7*7</td><td>显示结果</td></tr><tr><td><code>&lt;C-r></code> <code>=</code> 10/2</td><td>显示结果</td></tr></tbody></table></div>
<p>在 INSERT 模式下执行此操作</p>
<h3 id="shell">Shell<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#shell" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>:!&lt;shell></code></td><td>解释 Shell 命令</td></tr><tr><td><code>:r!&lt;shell></code></td><td>读入 shell 的输出</td></tr><tr><td><code>:r!date</code></td><td>插入日期</td></tr><tr><td><code>:!!date</code></td><td>用日期替换当前行</td></tr></tbody></table></div>
<h3 id="命令行">命令行<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#命令行" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<div class="table-container"><table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>&lt;C-r>&lt;C-w></code></td><td>将当前单词插入命令行</td></tr><tr><td><code>&lt;C-r>&quot;</code></td><td><code>注册</code> 粘贴</td></tr><tr><td><code>&lt;C-x>&lt;C-f></code></td><td>在插入模式下自动完成路径</td></tr></tbody></table></div>
<h3 id="技巧">技巧<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#技巧" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<p>删除重复行</p>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:sort | %</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">!</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">uniq -u</span></span></code></pre></figure>
<p>对文件中的行进行编号</p>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:%</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">!</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">cat -n</span></span></code></pre></figure>
<p>将整个文档复制到剪贴板</p>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:%w </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">!</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">pbcopy </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> Mac OS X</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:%w </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">!</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">xclip -i -</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">sel</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> c </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> GNU/Linux</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">:%w </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">!</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">xsel -i -b </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> GNU/Linux</span></span></code></pre></figure>
<h2 id="理解-vim">理解 Vim<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#理解-vim" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
<h3 id="动词理解">动词理解<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#动词理解" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">d </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示删除delete</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">r </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示替换replace</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">c </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示修改change</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">y </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示复制yank</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">v </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示选取visual select</span></span></code></pre></figure>
<p>动词代表了我们打算对文本进行什么样的操作</p>
<h3 id="名词理解">名词理解<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#名词理解" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">w </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示一个单词word</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">s </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示一个句子sentence</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">p </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示一个段落paragraph</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">t </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示一个 HTML 标签tag</span></span></code></pre></figure>
<p>名词代表了我们即将处理的文本。引号或者各种括号所包含的文本称作一个文本块。</p>
<h3 id="介词理解">介词理解<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#介词理解" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">i </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示在</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">...</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">之内 inside</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">a </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示环绕</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">...</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> around</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">t </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示到</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">...</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">位置前 </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">to</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">f </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 表示到</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">...</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">位置上 forward</span></span></code></pre></figure>
<p>介词界定了待编辑文本的范围或者位置。</p>
<h3 id="数词理解">数词理解<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#数词理解" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<p>数词指定了待编辑文本对象的数量,从这个角度而言,数词也可以看作是一种介词。引入数词之后,文本编辑命令的语法就升级成了下面这样:</p>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">动词 介词/数词 名词</span></span></code></pre></figure>
<p>下面是几个例子:</p>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">c3w </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 修改三个单词change three words</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">d2w </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 删除两个单词delete two words</span></span></code></pre></figure>
<p>另外,数词也可以修饰动词,表示将操作执行 <code>n</code> 次。于是,我们又有了下面的语法:</p>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">数词 动词 名词</span></span></code></pre></figure>
<p>示例</p>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">2dw </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 两次删除单词(等价于删除两个单词): twice delete word</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">3x </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 三次删除字符(等价于删除三个字符): three times delete character</span></span></code></pre></figure>
<h3 id="组词为句理解">组词为句理解<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#组词为句理解" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h3>
<p>有了这些基本的语言元素,我们就可以着手构造一些简单的命令了。文本编辑命令的基本语法如下:</p>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">动词 介词 名词</span></span></code></pre></figure>
<p>下面是一些例子</p>
<figure data-rehype-pretty-code-figure><pre tabindex="0" data-language="vim" data-theme="github-light github-dark"><code data-language="vim" data-theme="github-light github-dark" style="display:grid;"><span data-line><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">dip</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;"> #</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 删除一个段落: delete inside paragraph</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">vis </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 选取一个句子: visual select inside sentence</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">ciw </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 修改一个单词: change inside word</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">caw </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 修改一个单词: change around word</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">dtx </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 删除文本直到字符“x”(不包括字符“x”): delete </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">to</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> x</span></span>
<span data-line><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">dfx </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">#</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> 删除文本直到字符“x”(包括字符“x”): delete forward x</span></span></code></pre></figure>
<h2 id="另见">另见<a role="anchor" aria-hidden="true" tabindex="-1" data-no-popover="true" href="#另见" class="internal"><svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg></a></h2>
<ul>
<li><a href="https://jaywcjlove.github.io/vim-web" class="external">搞得像IDE一样的 Vim<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a> <em>(github.io)</em></li>
<li><a href="http://www.vim.org/" class="external">Vim 官方网站<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a> <em>(vim.org)</em></li>
<li><a href="https://devhints.io/vim" class="external">Devhints<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a> <em>(devhints.io)</em></li>
<li><a href="https://vim.rtorr.com/lang/zh_cn/" class="external">Vim cheatsheet<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a> <em>(vim.rotrr.com)</em></li>
<li><a href="http://vimdoc.sourceforge.net/htmldoc/" class="external">Vim documentation<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a> <em>(vimdoc.sourceforge.net)</em></li>
<li><a href="http://openvim.com/" class="external">Interactive Vim tutorial<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a> <em>(openvim.com)</em></li>
</ul>
<blockquote>
<p>来源:<a href="https://wangchujiang.com/reference/docs/vim.html" class="external">Vim 备忘清单 &amp; vim cheatsheet &amp; Quick Reference<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a>;仅学术引用,著作权归作者所有。</p>
</blockquote></article><hr/><div class="page-footer"></div></div><div class="right sidebar"><div class="graph"><h3>关系图谱</h3><div class="graph-outer"><div id="graph-container" data-cfg="{&quot;drag&quot;:true,&quot;zoom&quot;:true,&quot;depth&quot;:1,&quot;scale&quot;:1.1,&quot;repelForce&quot;:0.5,&quot;centerForce&quot;:0.3,&quot;linkDistance&quot;:30,&quot;fontSize&quot;:0.6,&quot;opacityScale&quot;:1,&quot;showTags&quot;:true,&quot;removeTags&quot;:[],&quot;focusOnHover&quot;:false}"></div><button id="global-graph-icon" aria-label="Global Graph"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 55 55" fill="currentColor" xml:space="preserve"><path d="M49,0c-3.309,0-6,2.691-6,6c0,1.035,0.263,2.009,0.726,2.86l-9.829,9.829C32.542,17.634,30.846,17,29,17
s-3.542,0.634-4.898,1.688l-7.669-7.669C16.785,10.424,17,9.74,17,9c0-2.206-1.794-4-4-4S9,6.794,9,9s1.794,4,4,4
c0.74,0,1.424-0.215,2.019-0.567l7.669,7.669C21.634,21.458,21,23.154,21,25s0.634,3.542,1.688,4.897L10.024,42.562
C8.958,41.595,7.549,41,6,41c-3.309,0-6,2.691-6,6s2.691,6,6,6s6-2.691,6-6c0-1.035-0.263-2.009-0.726-2.86l12.829-12.829
c1.106,0.86,2.44,1.436,3.898,1.619v10.16c-2.833,0.478-5,2.942-5,5.91c0,3.309,2.691,6,6,6s6-2.691,6-6c0-2.967-2.167-5.431-5-5.91
v-10.16c1.458-0.183,2.792-0.759,3.898-1.619l7.669,7.669C41.215,39.576,41,40.26,41,41c0,2.206,1.794,4,4,4s4-1.794,4-4
s-1.794-4-4-4c-0.74,0-1.424,0.215-2.019,0.567l-7.669-7.669C36.366,28.542,37,26.846,37,25s-0.634-3.542-1.688-4.897l9.665-9.665
C46.042,11.405,47.451,12,49,12c3.309,0,6-2.691,6-6S52.309,0,49,0z M11,9c0-1.103,0.897-2,2-2s2,0.897,2,2s-0.897,2-2,2
S11,10.103,11,9z M6,51c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S8.206,51,6,51z M33,49c0,2.206-1.794,4-4,4s-4-1.794-4-4
s1.794-4,4-4S33,46.794,33,49z M29,31c-3.309,0-6-2.691-6-6s2.691-6,6-6s6,2.691,6,6S32.309,31,29,31z M47,41c0,1.103-0.897,2-2,2
s-2-0.897-2-2s0.897-2,2-2S47,39.897,47,41z M49,10c-2.206,0-4-1.794-4-4s1.794-4,4-4s4,1.794,4,4S51.206,10,49,10z"></path></svg></button></div><div id="global-graph-outer"><div id="global-graph-container" data-cfg="{&quot;drag&quot;:true,&quot;zoom&quot;:true,&quot;depth&quot;:-1,&quot;scale&quot;:0.9,&quot;repelForce&quot;:0.5,&quot;centerForce&quot;:0.3,&quot;linkDistance&quot;:30,&quot;fontSize&quot;:0.6,&quot;opacityScale&quot;:1,&quot;showTags&quot;:true,&quot;removeTags&quot;:[],&quot;focusOnHover&quot;:true}"></div></div></div><div class="toc desktop-only"><button type="button" id="toc" class aria-controls="toc-content" aria-expanded="true"><h3>目录</h3><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="fold"><polyline points="6 9 12 15 18 9"></polyline></svg></button><div id="toc-content" class><ul class="overflow"><li class="depth-0"><a href="#入门" data-for="入门">入门</a></li><li class="depth-1"><a href="#运动图" data-for="运动图">运动图</a></li><li class="depth-1"><a href="#动作" data-for="动作">动作</a></li><li class="depth-1"><a href="#插入模式" data-for="插入模式">插入模式</a></li><li class="depth-1"><a href="#保存和退出" data-for="保存和退出">保存和退出</a></li><li class="depth-1"><a href="#正常模式" data-for="正常模式">正常模式</a></li><li class="depth-1"><a href="#剪切和粘贴" data-for="剪切和粘贴">剪切和粘贴</a></li><li class="depth-1"><a href="#重复" data-for="重复">重复</a></li><li class="depth-1"><a href="#可视化模式" data-for="可视化模式">可视化模式</a></li><li class="depth-1"><a href="#宏" data-for="宏"></a></li><li class="depth-0"><a href="#vim-运算符" data-for="vim-运算符">Vim 运算符</a></li><li class="depth-1"><a href="#用法" data-for="用法">用法</a></li><li class="depth-1"><a href="#可用运算符" data-for="可用运算符">可用运算符</a></li><li class="depth-1"><a href="#例子" data-for="例子">例子</a></li><li class="depth-1"><a href="#计数" data-for="计数">计数</a></li><li class="depth-0"><a href="#vim-文本对象" data-for="vim-文本对象">Vim 文本对象</a></li><li class="depth-1"><a href="#用法-1" data-for="用法-1">用法</a></li><li class="depth-1"><a href="#文本对象" data-for="文本对象">文本对象</a></li><li class="depth-1"><a href="#删除" data-for="删除">删除</a></li><li class="depth-1"><a href="#选择" data-for="选择">选择</a></li><li class="depth-1"><a href="#杂项" data-for="杂项">杂项</a></li><li class="depth-0"><a href="#vim-多个文件" data-for="vim-多个文件">Vim 多个文件</a></li><li class="depth-1"><a href="#buffers-缓冲器" data-for="buffers-缓冲器">Buffers (缓冲器)</a></li><li class="depth-1"><a href="#窗口" data-for="窗口">窗口</a></li><li class="depth-1"><a href="#选项卡" data-for="选项卡">选项卡</a></li><li class="depth-0"><a href="#vim-搜索和替换" data-for="vim-搜索和替换">Vim 搜索和替换</a></li><li class="depth-1"><a href="#搜索" data-for="搜索">搜索</a></li><li class="depth-1"><a href="#更换行" data-for="更换行">更换行</a></li><li class="depth-1"><a href="#替换文件" data-for="替换文件">替换文件</a></li><li class="depth-1"><a href="#范围" data-for="范围">范围</a></li><li class="depth-1"><a href="#全局命令" data-for="全局命令">全局命令</a></li><li class="depth-1"><a href="#inverse逆-g" data-for="inverse逆-g">Inverse(逆) :g</a></li><li class="depth-1"><a href="#flags标志" data-for="flags标志">Flags(标志)</a></li><li class="depth-1"><a href="#替换表达式魔术" data-for="替换表达式魔术">替换表达式(魔术)</a></li><li class="depth-1"><a href="#例子-1" data-for="例子-1">例子</a></li><li class="depth-0"><a href="#vimdiff" data-for="vimdiff">Vimdiff</a></li><li class="depth-1"><a href="#用法-2" data-for="用法-2">用法</a></li><li c
</script><script type="module">
let mermaidImport = undefined
document.addEventListener('nav', async () => {
if (document.querySelector("code.mermaid")) {
mermaidImport ||= await import('https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.7.0/mermaid.esm.min.mjs')
const mermaid = mermaidImport.default
const darkMode = document.documentElement.getAttribute('saved-theme') === 'dark'
mermaid.initialize({
startOnLoad: false,
securityLevel: 'loose',
theme: darkMode ? 'dark' : 'default'
})
await mermaid.run({
querySelector: '.mermaid'
})
}
});
</script><script src="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.16.9/contrib/copy-tex.min.js" type="application/javascript"></script><script src="../../../../postscript.js" type="module"></script></html>