1957 lines
531 KiB
HTML
1957 lines
531 KiB
HTML
|
<!DOCTYPE html>
|
|||
|
<html><head><title>Vim 快速入门</title><meta charSet="utf-8"/><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 rel="preconnect" href="https://fonts.googleapis.com"/><link rel="preconnect" href="https://fonts.gstatic.com"/><script async src="https://umami.7wate.com/script.js" data-website-id="c061efdc-95dd-4d21-9d04-a1ffda0a85b9"></script><script>
|
|||
|
var _hmt = _hmt || [];
|
|||
|
(function() {
|
|||
|
var hm = document.createElement("script");
|
|||
|
hm.src = "https://hm.baidu.com/hm.js?94d8ccb156eb7c65abf317e6e01cdba9";
|
|||
|
var s = document.getElementsByTagName("script")[0];
|
|||
|
s.parentNode.insertBefore(hm, s);
|
|||
|
})();
|
|||
|
</script><script async src="https://www.googletagmanager.com/gtag/js?id=G-MHMEL0F832"></script><script>
|
|||
|
(function() {
|
|||
|
window.dataLayer = window.dataLayer || [];
|
|||
|
function gtag() {
|
|||
|
window.dataLayer.push(arguments);
|
|||
|
}
|
|||
|
gtag('js', new Date());
|
|||
|
gtag('config', 'G-MHMEL0F832');
|
|||
|
})();
|
|||
|
</script><link href="../../../../index.css" rel="stylesheet" type="text/css" spa-preserve/><link href="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css" rel="stylesheet" type="text/css" spa-preserve/><link href="https://fonts.googleapis.com/css2?family=IBM Plex Mono&family=Schibsted Grotesk:wght@400;700&family=Source Sans Pro:ital,wght@0,400;0,600;1,400;1,600&display=swap" 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"><h1 class="page-title "><a href="../../../..">📚 X·Eden</a></h1><div class="spacer mobile-only"></div><div class="search "><div id="search-icon"><p>Search</p><div></div><svg tabIndex="0" aria-labelledby="title desc" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19.9 19.7"><title id="title">Search</title><desc id="desc">Search</desc><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></div><div id="search-container"><div id="search-space"><input autocomplete="off" id="search-bar" name="search" type="text" aria-label="Search for something" placeholder="Search for something"/><div id="results-container"></div></div></div></div><div class="darkmode "><input class="toggle" id="darkmode-toggle" type="checkbox" tabIndex="-1"/><label id="toggle-label-light" for="darkmode-toggle" tabIndex="-1"><svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="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;" xmlSpace="preserve"><title>Light mode</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,7,17.5,7z M17.5,25c-4.136,0-7.5-3.364-7.5-7.5 c0-4.136,3.364-7.5,7.5-7.5c4.136,0,7.5,3.364,7.5,7.5C25,21.636,21.636,25,17.5,25z"></path></svg></label><label id="toggle-label-dark" for="darkmode-toggle" tabIndex="-1"><svg xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" version="1.1" id="nightIcon" x="0px" y="0px" viewBox="0 0 100 100" style="enable-background='new 0 0 100 100'" xmlSpace="preserve"><title>Dark mode</title><path d="M96.76,66.458c-0.853-0.852-2.15-1.064-3.23-0.534c-6.063,2.991-12.858,4.571-19.655,4.571 C62.022,70.495,50.88,65.88,42.5,57.5C29.043,44.043,25.658,23.536,34.076,6.47c0.532-1.08,0.318-2.379-0.534-3.23 c-0.851-0.852-2.15-1.064-3.23-0.534c-4.918,2.427-9.375,5.619-13.246,9.491c-9.447,9.447-14.65,22.008
|
|||
|
<h2 id="入门">入门<a aria-hidden="true" tabindex="-1" href="#入门" class="internal"> §</a></h2>
|
|||
|
<h3 id="运动图">运动图<a aria-hidden="true" tabindex="-1" href="#运动图" class="internal"> §</a></h3>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">▼</span><span style="color:var(--shiki-token-string-expression);">/▶ 光标 ▽/</span><span style="color:var(--shiki-color-text);">▷ 目标</span></span></code></pre></div>
|
|||
|
<h4 id="左右动作">左右动作<a aria-hidden="true" tabindex="-1" href="#左右动作" class="internal"> §</a></h4>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">╭┈┈┈┈┈┈┈┈┈┈┈┈┈ | </span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">├┈┈┈┈┈┈┈┈┈┈┈┈┈ </span><span style="color:var(--shiki-token-constant);">0</span><span style="color:var(--shiki-color-text);"> $ ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈╮</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">┆ ╭┈┈┈┈┈┈┈┈┈┈ ^ fe ┈┈┈┈┈┈┈┈╮ ┆</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">┆ ┆ ╭┈┈┈┈┈┈┈ Fo te ┈┈┈┈┈┈┈╮┆ ┆</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">┆ ┆ ┆╭┈┈┈┈┈┈ To </span><span style="color:var(--shiki-token-constant);">30</span><span style="color:var(--shiki-color-text);">| ┈┈┈╮ ┆┆ ┆</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">┆ ┆ ┆┆ ╭┈┈┈┈ ge w ┈┈┈╮ ┆ ┆┆ ┆</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">┆ ┆ ┆┆ ┆ ╭┈┈ b e ┈╮ ┆ ┆ ┆┆ ┆</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">┆ ┆ ┆┆ ┆ ┆ ╭h l╮ ┆ ┆ ┆ ┆┆ ┆</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">▽ ▽ ▽▽ ▽ ▽ ▽▼ ▼▽ ▽ ▽ ▽ ▽▽ ▽</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-function);">echo</span><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-string-expression);">"A cheatsheet from quickReference"</span></span></code></pre></div>
|
|||
|
<h4 id="上下动作">上下动作<a aria-hidden="true" tabindex="-1" href="#上下动作" class="internal"> §</a></h4>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-keyword);"> - </span><span style="color:var(--shiki-color-text);">SCREEN </span><span style="color:var(--shiki-token-constant);">1</span><span style="color:var(--shiki-color-text);"> START</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);"> ╭┈┬┈┈┈┈┈┈┈┈┈▷ </span><span style="color:var(--shiki-token-keyword);">#!</span><span style="color:var(--shiki-token-string-expression);">/usr/</span><span style="color:var(--shiki-token-constant);">bin</span><span style="color:var(--shiki-color-text);">/python</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);"> ┆ ┆ ╭┈┈┈▷ </span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);"> ┆ ┆ ┆ </span><span style="color:var(--shiki-token-function);">print</span><span style="color:var(--shiki-color-text);">(</span><span style="color:var(--shiki-token-string-expression);">"Hello"</span><span style="color:var(--shiki-color-text);">)</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);"> ┆ ┆ { } ▶ </span><span style="color:var(--shiki-token-function);">print</span><span style="color:var(--shiki-color-text);">(</span><span style="color:var(--shiki-token-string-expression);">"Vim"</span><span style="color:var(--shiki-color-text);">)</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);"> ┆ ┆ ┆ </span><span style="color:var(--shiki-token-function);">print</span><span style="color:var(--shiki-color-text);">(</span><span style="color:var(--shiki-token-string-expression);">"!"</span><span style="color:var(--shiki-color-text);">)</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);"> ┆ ┆ └┈▷ </span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);"> ┆ ┆ ╭┈┈┈┬┈┈┈▷ </span><span style="color:var(--shiki-token-function);">print</span><span style="color:var(--shiki-color-text);">(</span><span style="color:var(--shiki-token-string-expression);">"Welcome"</span><span style="color:var(--shiki-color-text);">)</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">G gg H M L k j ▶ </span><span style="color:var(--shiki-token-function);">print</span><span style="color:var(--shiki-color-text);">(</span><span style="color:var(--shiki-token-string-expression);">"to"</span><span style="color:var(--shiki-color-text);">)</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">┆ ┆ └┈▷ </span><span style="color:var(--shiki-token-function);">print</span><span style="color:var(--shiki-color-text);">(</span><span style="color:var(--shiki-token-string-expression);">"Quick Reference"</span><span style="color:var(--shiki-color-text);">)</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">┆ ┆ </span><span style="color:var(--shiki-token-function);">print</span><span style="color:var(--shiki-color-text);">(</span><span style="color:var(--shiki-token-string-expression);">"/vim"</span><span style="color:var(--shiki-color-text);">)</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">┆ ┆ </span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">┆ ╰┈┈┈┈┈▷ </span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">┆ </span><span style="color:var(--shiki-token-keyword);"> - </span><span style="color:var(--shiki-color-text);">SCREEN </span><span style="color:var(--shiki-token-constant);">1</span><span style="color:var(--shiki-color-text);"> END</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">╰┈┈┈┈┈┈┈┈┈┈┈┈┈┈▷ </span><span style="color:var(--shiki-token-function);">print</span><span style="color:var(--shiki-color-text);">(</span><span style="color:var(--shiki-token-string-expression);">"SCREEN 2"</span><span style="color:var(--shiki-color-text);">)</span></span></code></pre></div>
|
|||
|
<h3 id="动作">动作<a aria-hidden="true" tabindex="-1" href="#动作" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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><C-u></code> <em>/</em> <code><C-d></code></td><td>上/下半页</td></tr><tr><td><code><C-b></code> <em>/</em> <code><C-f></code></td><td>向上/向下翻页</td></tr></tbody></table>
|
|||
|
<h4 id="字-词">字 (词)<a aria-hidden="true" tabindex="-1" href="#字-词" class="internal"> §</a></h4>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h4 id="行">行<a aria-hidden="true" tabindex="-1" href="#行" class="internal"> §</a></h4>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h4 id="字符串">字符串<a aria-hidden="true" tabindex="-1" href="#字符串" class="internal"> §</a></h4>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h4 id="文档">文档<a aria-hidden="true" tabindex="-1" href="#文档" class="internal"> §</a></h4>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h4 id="窗口">窗口<a aria-hidden="true" tabindex="-1" href="#窗口" class="internal"> §</a></h4>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="插入模式">插入模式<a aria-hidden="true" tabindex="-1" href="#插入模式" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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><C-[></code></td></tr></tbody></table>
|
|||
|
<h3 id="保存和退出">保存和退出<a aria-hidden="true" tabindex="-1" href="#保存和退出" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="正常模式">正常模式<a aria-hidden="true" tabindex="-1" href="#正常模式" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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><C-r></code> <em>/</em> 5 <code><C-r></code></td><td>重做更改 <code>1</code>/<code>5</code> 次</td></tr></tbody></table>
|
|||
|
<h3 id="剪切和粘贴">剪切和粘贴<a aria-hidden="true" tabindex="-1" href="#剪切和粘贴" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>"*p</code></td><td><code>"+p</code></td></tr><tr><td><code>"*y</code></td><td><code>"+y</code></td></tr></tbody></table>
|
|||
|
<h4 id="在可视化模式下">在可视化模式下<a aria-hidden="true" tabindex="-1" href="#在可视化模式下" class="internal"> §</a></h4>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="重复">重复<a aria-hidden="true" tabindex="-1" href="#重复" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>&</code></td><td>重复最后一个 <code>:s</code></td></tr><tr><td><code>@:</code></td><td>重复命令行命令</td></tr></tbody></table>
|
|||
|
<h3 id="可视化模式">可视化模式<a aria-hidden="true" tabindex="-1" href="#可视化模式" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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><C-v></code></td><td>进入可视化阻挡模式</td></tr><tr><td><code>ggVG</code></td><td>选择所有文本</td></tr><tr><td><code>></code> <em>/</em> <code><</code></td><td>向右/向左移动文本</td></tr></tbody></table>
|
|||
|
<h3 id="宏">宏<a aria-hidden="true" tabindex="-1" href="#宏" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<p>您可以为任何字母保存宏,而不仅仅是 <code>i</code></p>
|
|||
|
<h2 id="vim-运算符">Vim 运算符<a aria-hidden="true" tabindex="-1" href="#vim-运算符" class="internal"> §</a></h2>
|
|||
|
<h3 id="用法">用法<a aria-hidden="true" tabindex="-1" href="#用法" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<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">可用运算符</a> 与 <a href="https://github.com/jaywcjlove/reference/blob/main/docs/vim.md#%E5%8A%A8%E4%BD%9C" class="external">动作</a> 结合使用以使用它们</p>
|
|||
|
<h3 id="可用运算符">可用运算符<a aria-hidden="true" tabindex="-1" href="#可用运算符" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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><</code></td><td>左缩进</td></tr><tr><td><code>!</code></td><td>通过外部程序过滤</td></tr></tbody></table>
|
|||
|
<h3 id="例子">例子<a aria-hidden="true" tabindex="-1" href="#例子" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="计数">计数<a aria-hidden="true" tabindex="-1" href="#计数" class="internal"> §</a></h3>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">[数字] <运算符> <动作></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);"><运算符> [数字] <动作></span></span></code></pre></div>
|
|||
|
<hr/>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h2 id="vim-文本对象">Vim 文本对象<a aria-hidden="true" tabindex="-1" href="#vim-文本对象" class="internal"> §</a></h2>
|
|||
|
<h3 id="用法-1">用法<a aria-hidden="true" tabindex="-1" href="#用法-1" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<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</a> 进行操作</p>
|
|||
|
<h3 id="文本对象">文本对象<a aria-hidden="true" tabindex="-1" href="#文本对象" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>[ ( { <</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>
|
|||
|
<p>查看 <code>:help text-objects</code></p>
|
|||
|
<h3 id="删除">删除<a aria-hidden="true" tabindex="-1" href="#删除" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="选择">选择<a aria-hidden="true" tabindex="-1" href="#选择" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>"..."</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>
|
|||
|
<h3 id="杂项">杂项<a aria-hidden="true" tabindex="-1" href="#杂项" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h2 id="vim-多个文件">Vim 多个文件<a aria-hidden="true" tabindex="-1" href="#vim-多个文件" class="internal"> §</a></h2>
|
|||
|
<h3 id="buffers-缓冲器">Buffers (缓冲器)<a aria-hidden="true" tabindex="-1" href="#buffers-缓冲器" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="窗口-1">窗口<a aria-hidden="true" tabindex="-1" href="#窗口-1" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code><C-w></code> <code>s</code></td><td>拆分窗口</td></tr><tr><td><code><C-w></code> <code>v</code></td><td>垂直拆分窗口</td></tr><tr><td><code><C-w></code> <code>w</code></td><td>切换窗口</td></tr><tr><td><code><C-w></code> <code>q</code></td><td>退出一个窗口</td></tr><tr><td><code><C-w></code> <code>T</code></td><td>拆分成一个新标签</td></tr><tr><td><code><C-w></code> <code>x</code></td><td>用下一个交换当前</td></tr><tr><td><code><C-w></code> <code>-</code> <em>/</em> <code>+</code></td><td>减少/增加高度</td></tr><tr><td><code><C-w></code> <code><</code> <em>/</em> <code>></code></td><td>减少/增加宽度</td></tr><tr><td><code><C-w></code> `</td><td>`</td></tr><tr><td><code><C-w></code> <code>=</code></td><td>同样高和宽</td></tr><tr><td><code><C-w></code> <code>h</code> <em>/</em> <code>l</code></td><td>转到左/右窗口</td></tr><tr><td><code><C-w></code> <code>j</code> <em>/</em> <code>k</code></td><td>转到上/下窗口</td></tr></tbody></table>
|
|||
|
<h3 id="选项卡">选项卡<a aria-hidden="true" tabindex="-1" href="#选项卡" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h4 id="正常模式-1">正常模式<a aria-hidden="true" tabindex="-1" href="#正常模式-1" class="internal"> §</a></h4>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h2 id="vim-搜索和替换">Vim 搜索和替换<a aria-hidden="true" tabindex="-1" href="#vim-搜索和替换" class="internal"> §</a></h2>
|
|||
|
<h3 id="搜索">搜索<a aria-hidden="true" tabindex="-1" href="#搜索" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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</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>
|
|||
|
<h3 id="更换行">更换行<a aria-hidden="true" tabindex="-1" href="#更换行" class="internal"> §</a></h3>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">:[</span><span style="color:var(--shiki-token-keyword);">range</span><span style="color:var(--shiki-color-text);">]s</span><span style="color:var(--shiki-token-string-expression);">/{pattern}/</span><span style="color:var(--shiki-color-text);">{str}/[flags]</span></span></code></pre></div>
|
|||
|
<hr/>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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</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>
|
|||
|
<h3 id="替换文件">替换文件<a aria-hidden="true" tabindex="-1" href="#替换文件" class="internal"> §</a></h3>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">:%s</span><span style="color:var(--shiki-token-string-expression);">/{pattern}/</span><span style="color:var(--shiki-color-text);">{str}/[flags]</span></span></code></pre></div>
|
|||
|
<hr/>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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</a></td></tr></tbody></table>
|
|||
|
<h3 id="范围">范围<a aria-hidden="true" tabindex="-1" href="#范围" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>%</code></td><td>整个文件</td></tr><tr><td><code>’<,’></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>
|
|||
|
<h3 id="全局命令">全局命令<a aria-hidden="true" tabindex="-1" href="#全局命令" class="internal"> §</a></h3>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">:[</span><span style="color:var(--shiki-token-keyword);">range</span><span style="color:var(--shiki-color-text);">]g</span><span style="color:var(--shiki-token-string-expression);">/{pattern}/</span><span style="color:var(--shiki-color-text);">[command]</span></span></code></pre></div>
|
|||
|
<hr/>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="inverse逆-g">Inverse(逆) :g<a aria-hidden="true" tabindex="-1" href="#inverse逆-g" class="internal"> §</a></h3>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">:[</span><span style="color:var(--shiki-token-keyword);">range</span><span style="color:var(--shiki-color-text);">]v</span><span style="color:var(--shiki-token-string-expression);">/{pattern}/</span><span style="color:var(--shiki-color-text);">[command]</span></span></code></pre></div>
|
|||
|
<hr/>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="flags标志">Flags(标志)<a aria-hidden="true" tabindex="-1" href="#flags标志" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="替换表达式魔术">替换表达式(魔术)<a aria-hidden="true" tabindex="-1" href="#替换表达式魔术" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>&</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>
|
|||
|
<h3 id="例子-1">例子<a aria-hidden="true" tabindex="-1" href="#例子-1" class="internal"> §</a></h3>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">:s</span><span style="color:var(--shiki-token-string-expression);">/a\|b/</span><span style="color:var(--shiki-color-text);">xxx</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">0xxx/g </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 将 </span><span style="color:var(--shiki-token-string-expression);">"a b"</span><span style="color:var(--shiki-color-text);"> 修改为 </span><span style="color:var(--shiki-token-string-expression);">"xxxaxxx xxxbxxx"</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:s</span><span style="color:var(--shiki-token-string-expression);">/test/</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">U& file/ </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 将 </span><span style="color:var(--shiki-token-string-expression);">"test"</span><span style="color:var(--shiki-color-text);"> 修改为 </span><span style="color:var(--shiki-token-string-expression);">"TEST FILE"</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:s</span><span style="color:var(--shiki-token-string-expression);">/\(test\)/</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">U</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-token-constant);">1</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">e file/ </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 将 </span><span style="color:var(--shiki-token-string-expression);">"test"</span><span style="color:var(--shiki-color-text);"> 修改为 </span><span style="color:var(--shiki-token-string-expression);">"TEST file"</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:s</span><span style="color:var(--shiki-token-string-expression);">/\v([abc])([efg])/</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-token-constant);">2</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-token-constant);">1</span><span style="color:var(--shiki-color-text);">/g </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 将 </span><span style="color:var(--shiki-token-string-expression);">"af fa bg"</span><span style="color:var(--shiki-color-text);"> 修改为 </span><span style="color:var(--shiki-token-string-expression);">"fa fa gb"</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:s</span><span style="color:var(--shiki-token-string-expression);">/\v\w+/</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">u</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-token-constant);">0</span><span style="color:var(--shiki-color-text);">/g </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 将 </span><span style="color:var(--shiki-token-string-expression);">"bla bla"</span><span style="color:var(--shiki-color-text);"> 修改为 </span><span style="color:var(--shiki-token-string-expression);">"Bla Bla"</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:s</span><span style="color:var(--shiki-token-string-expression);">/\v([ab])|([cd])/</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">1x/g </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 将 </span><span style="color:var(--shiki-token-string-expression);">"a b c d"</span><span style="color:var(--shiki-color-text);"> 修改为 </span><span style="color:var(--shiki-token-string-expression);">"ax bx x x"</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:%s</span><span style="color:var(--shiki-token-string-expression);">/.*/</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">L&/ </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 将 </span><span style="color:var(--shiki-token-string-expression);">"HTML"</span><span style="color:var(--shiki-color-text);"> 修改为 </span><span style="color:var(--shiki-token-string-expression);">"html"</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:s</span><span style="color:var(--shiki-token-string-expression);">/\v<(.)(\w*)/</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">u</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-token-constant);">1</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">L</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-token-constant);">2</span><span style="color:var(--shiki-color-text);">/g </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 将单词的每个首字母大写</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:%s</span><span style="color:var(--shiki-token-string-expression);">/^\(.*\)\n\1/</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-token-constant);">1</span><span style="color:var(--shiki-color-text);">/ </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 删除重复行</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:%s</span><span style="color:var(--shiki-token-string-expression);">/<\/\=\(\w\+\)\>/</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">U&/g </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 将 HTML 标记转换为大写</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:g</span><span style="color:var(--shiki-token-string-expression);">/^pattern/</span><span style="color:var(--shiki-color-text);">s</span><span style="color:var(--shiki-token-string-expression);">/$/</span><span style="color:var(--shiki-color-text);">mytext </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 查找文本并将其附加到末尾</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:g</span><span style="color:var(--shiki-token-string-expression);">/pattern/</span><span style="color:var(--shiki-color-text);">norm</span><span style="color:var(--shiki-token-keyword);">!</span><span style="color:var(--shiki-color-text);"> @i </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 在匹配行上运行宏</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">/^</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">(.*</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">)</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">(</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">r</span><span style="color:var(--shiki-token-keyword);">\?\</span><span style="color:var(--shiki-color-text);">n</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-token-constant);">1</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">)</span><span style="color:var(--shiki-token-keyword);">\+</span><span style="color:var(--shiki-color-text);">$ </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 查看重复行</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">/</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">v^(.*)(</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-color-text);">r</span><span style="color:var(--shiki-token-keyword);">?\</span><span style="color:var(--shiki-color-text);">n</span><span style="color:var(--shiki-token-keyword);">\</span><span style="color:var(--shiki-token-constant);">1</span><span style="color:var(--shiki-color-text);">)</span><span style="color:var(--shiki-token-keyword);">+</span><span style="color:var(--shiki-color-text);">$ </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 查看重复行(非常神奇)</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:v</span><span style="color:var(--shiki-token-string-expression);">/./</span><span style="color:var(--shiki-color-text);">,</span><span style="color:var(--shiki-token-string-expression);">/./</span><span style="color:var(--shiki-color-text);">-j </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 将空行压缩成空行</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:g</span><span style="color:var(--shiki-token-string-expression);">/<p1>/</span><span style="color:var(--shiki-color-text);">,</span><span style="color:var(--shiki-token-string-expression);">/<p2>/</span><span style="color:var(--shiki-color-text);">d </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 从 <p1> 到 <p2> 包含删除</span></span></code></pre></div>
|
|||
|
<h2 id="vimdiff">Vimdiff<a aria-hidden="true" tabindex="-1" href="#vimdiff" class="internal"> §</a></h2>
|
|||
|
<h3 id="用法-2">用法<a aria-hidden="true" tabindex="-1" href="#用法-2" class="internal"> §</a></h3>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">vimdiff file1 file2 [file3]</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">vim -d file1 file2 [file3]</span></span></code></pre></div>
|
|||
|
<h3 id="编辑">编辑<a aria-hidden="true" tabindex="-1" href="#编辑" class="internal"> §</a></h3>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">:[</span><span style="color:var(--shiki-token-keyword);">range</span><span style="color:var(--shiki-color-text);">]diffget [bufspec]</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:[</span><span style="color:var(--shiki-token-keyword);">range</span><span style="color:var(--shiki-color-text);">]diffput [bufspec]</span></span></code></pre></div>
|
|||
|
<hr/>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<p>请参阅:<a href="https://github.com/jaywcjlove/reference/blob/main/docs/vim.md#%E8%8C%83%E5%9B%B4" class="external">范围</a></p>
|
|||
|
<h3 id="折叠">折叠<a aria-hidden="true" tabindex="-1" href="#折叠" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="跳跃">跳跃<a aria-hidden="true" tabindex="-1" href="#跳跃" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h2 id="各种各样的">各种各样的<a aria-hidden="true" tabindex="-1" href="#各种各样的" class="internal"> §</a></h2>
|
|||
|
<h3 id="case">Case<a aria-hidden="true" tabindex="-1" href="#case" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="跳跃-1">跳跃<a aria-hidden="true" tabindex="-1" href="#跳跃-1" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code><C-o></code></td><td>返回上一个</td></tr><tr><td><code><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>
|
|||
|
<h3 id="其他命令行">其他命令行<a aria-hidden="true" tabindex="-1" href="#其他命令行" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="导航">导航<a aria-hidden="true" tabindex="-1" href="#导航" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<h3 id="计数器">计数器<a aria-hidden="true" tabindex="-1" href="#计数器" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code><C-a></code></td><td>增加数量</td></tr><tr><td><code><C-x></code></td><td>减少数量</td></tr></tbody></table>
|
|||
|
<h3 id="选项卡-1">选项卡<a aria-hidden="true" tabindex="-1" href="#选项卡-1" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code>:tag Classname</code></td><td>跳转到 Classname 的第一个定义</td></tr><tr><td><code><C-]></code></td><td>跳转到定义</td></tr><tr><td><code>g]</code></td><td>查看所有定义</td></tr><tr><td><code><C-t></code></td><td>回到最后一个标签</td></tr><tr><td><code><C-o> <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>
|
|||
|
<h3 id="格式化">格式化<a aria-hidden="true" tabindex="-1" href="#格式化" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>
|
|||
|
<p>查看 <code>:help formatting</code></p>
|
|||
|
<h3 id="标记">标记<a aria-hidden="true" tabindex="-1" href="#标记" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<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>“<`</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>
|
|||
|
<h3 id="计算器">计算器<a aria-hidden="true" tabindex="-1" href="#计算器" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code><C-r></code> <code>=</code> 7*7</td><td>显示结果</td></tr><tr><td><code><C-r></code> <code>=</code> 10/2</td><td>显示结果</td></tr></tbody></table>
|
|||
|
<p>在 INSERT 模式下执行此操作</p>
|
|||
|
<h3 id="shell">Shell<a aria-hidden="true" tabindex="-1" href="#shell" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>:-</th><th>-</th></tr></thead><tbody><tr><td><code>:!<shell></code></td><td>解释 Shell 命令</td></tr><tr><td><code>:r!<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>
|
|||
|
<h3 id="命令行">命令行<a aria-hidden="true" tabindex="-1" href="#命令行" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>快捷方式</th><th>说明</th></tr></thead><tbody><tr><td><code><C-r><C-w></code></td><td>将当前单词插入命令行</td></tr><tr><td><code><C-r>"</code></td><td>从 <code>注册</code> 粘贴</td></tr><tr><td><code><C-x><C-f></code></td><td>在插入模式下自动完成路径</td></tr></tbody></table>
|
|||
|
<h3 id="技巧">技巧<a aria-hidden="true" tabindex="-1" href="#技巧" class="internal"> §</a></h3>
|
|||
|
<p>删除重复行</p>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">:sort | %</span><span style="color:var(--shiki-token-keyword);">!</span><span style="color:var(--shiki-color-text);">uniq -u</span></span></code></pre></div>
|
|||
|
<p>对文件中的行进行编号</p>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">:%</span><span style="color:var(--shiki-token-keyword);">!</span><span style="color:var(--shiki-color-text);">cat -n</span></span></code></pre></div>
|
|||
|
<p>将整个文档复制到剪贴板</p>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">:%w </span><span style="color:var(--shiki-token-keyword);">!</span><span style="color:var(--shiki-color-text);">pbcopy </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> Mac OS X</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:%w </span><span style="color:var(--shiki-token-keyword);">!</span><span style="color:var(--shiki-color-text);">xclip -i -</span><span style="color:var(--shiki-token-constant);">sel</span><span style="color:var(--shiki-color-text);"> c </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> GNU/Linux</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">:%w </span><span style="color:var(--shiki-token-keyword);">!</span><span style="color:var(--shiki-color-text);">xsel -i -b </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> GNU/Linux</span></span></code></pre></div>
|
|||
|
<h2 id="理解-vim">理解 Vim<a aria-hidden="true" tabindex="-1" href="#理解-vim" class="internal"> §</a></h2>
|
|||
|
<h3 id="动词理解">动词理解<a aria-hidden="true" tabindex="-1" href="#动词理解" class="internal"> §</a></h3>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">d </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示删除delete</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">r </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示替换replace</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">c </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示修改change</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">y </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示复制yank</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">v </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示选取visual select</span></span></code></pre></div>
|
|||
|
<p>动词代表了我们打算对文本进行什么样的操作</p>
|
|||
|
<h3 id="名词理解">名词理解<a aria-hidden="true" tabindex="-1" href="#名词理解" class="internal"> §</a></h3>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">w </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示一个单词word</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">s </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示一个句子sentence</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">p </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示一个段落paragraph</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">t </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示一个 HTML 标签tag</span></span></code></pre></div>
|
|||
|
<p>名词代表了我们即将处理的文本。引号或者各种括号所包含的文本称作一个文本块。</p>
|
|||
|
<h3 id="介词理解">介词理解<a aria-hidden="true" tabindex="-1" href="#介词理解" class="internal"> §</a></h3>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">i </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示在</span><span style="color:var(--shiki-token-keyword);">...</span><span style="color:var(--shiki-color-text);">之内 inside</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">a </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示环绕</span><span style="color:var(--shiki-token-keyword);">...</span><span style="color:var(--shiki-color-text);"> around</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">t </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示到</span><span style="color:var(--shiki-token-keyword);">...</span><span style="color:var(--shiki-color-text);">位置前 </span><span style="color:var(--shiki-token-constant);">to</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">f </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 表示到</span><span style="color:var(--shiki-token-keyword);">...</span><span style="color:var(--shiki-color-text);">位置上 forward</span></span></code></pre></div>
|
|||
|
<p>介词界定了待编辑文本的范围或者位置。</p>
|
|||
|
<h3 id="数词理解">数词理解<a aria-hidden="true" tabindex="-1" href="#数词理解" class="internal"> §</a></h3>
|
|||
|
<p>数词指定了待编辑文本对象的数量,从这个角度而言,数词也可以看作是一种介词。引入数词之后,文本编辑命令的语法就升级成了下面这样:</p>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">动词 介词/数词 名词</span></span></code></pre></div>
|
|||
|
<p>下面是几个例子:</p>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">c3w </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 修改三个单词:change three words</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">d2w </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 删除两个单词:delete two words</span></span></code></pre></div>
|
|||
|
<p>另外,数词也可以修饰动词,表示将操作执行 <code>n</code> 次。于是,我们又有了下面的语法:</p>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">数词 动词 名词</span></span></code></pre></div>
|
|||
|
<p>示例</p>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">2dw </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 两次删除单词(等价于删除两个单词): twice delete word</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">3x </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 三次删除字符(等价于删除三个字符): three times delete character</span></span></code></pre></div>
|
|||
|
<h3 id="组词为句理解">组词为句理解<a aria-hidden="true" tabindex="-1" href="#组词为句理解" class="internal"> §</a></h3>
|
|||
|
<p>有了这些基本的语言元素,我们就可以着手构造一些简单的命令了。文本编辑命令的基本语法如下:</p>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-color-text);">动词 介词 名词</span></span></code></pre></div>
|
|||
|
<p>下面是一些例子</p>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="vim" data-theme="default"><code data-language="vim" data-theme="default"><span data-line><span style="color:var(--shiki-token-constant);">dip</span><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 删除一个段落: delete inside paragraph</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">vis </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 选取一个句子: visual select inside sentence</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">ciw </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 修改一个单词: change inside word</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">caw </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 修改一个单词: change around word</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">dtx </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 删除文本直到字符“x”(不包括字符“x”): delete </span><span style="color:var(--shiki-token-constant);">to</span><span style="color:var(--shiki-color-text);"> x</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">dfx </span><span style="color:var(--shiki-token-keyword);">#</span><span style="color:var(--shiki-color-text);"> 删除文本直到字符“x”(包括字符“x”): delete forward x</span></span></code></pre></div>
|
|||
|
<h2 id="另见">另见<a aria-hidden="true" tabindex="-1" href="#另见" class="internal"> §</a></h2>
|
|||
|
<ul>
|
|||
|
<li><a href="https://jaywcjlove.github.io/vim-web" class="external">搞得像IDE一样的 Vim</a> <em>(github.io)</em></li>
|
|||
|
<li><a href="http://www.vim.org/" class="external">Vim 官方网站</a> <em>(vim.org)</em></li>
|
|||
|
<li><a href="https://devhints.io/vim" class="external">Devhints</a> <em>(devhints.io)</em></li>
|
|||
|
<li><a href="https://vim.rtorr.com/lang/zh_cn/" class="external">Vim cheatsheet</a> <em>(vim.rotrr.com)</em></li>
|
|||
|
<li><a href="http://vimdoc.sourceforge.net/htmldoc/" class="external">Vim documentation</a> <em>(vimdoc.sourceforge.net)</em></li>
|
|||
|
<li><a href="http://openvim.com/" class="external">Interactive Vim tutorial</a> <em>(openvim.com)</em></li>
|
|||
|
</ul>
|
|||
|
<blockquote>
|
|||
|
<p>来源:<a href="https://wangchujiang.com/reference/docs/vim.html" class="external">Vim 备忘清单 & vim cheatsheet & Quick Reference</a>;仅学术引用,著作权归作者所有。</p>
|
|||
|
</blockquote></article></div><div class="right sidebar"><div class="graph "><h3>Graph View</h3><div class="graph-outer"><div id="graph-container" data-cfg="{"drag":true,"zoom":true,"depth":1,"scale":1.1,"repelForce":0.5,"centerForce":0.3,"linkDistance":30,"fontSize":0.6,"opacityScale":1,"showTags":true,"removeTags":[]}"></div><svg version="1.1" id="global-graph-icon" xmlns="http://www.w3.org/2000/svg" xmlnsXlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 55 55" fill="currentColor" xmlSpace="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></div><div id="global-graph-outer"><div id="global-graph-container" data-cfg="{"drag":true,"zoom":true,"depth":-1,"scale":0.9,"repelForce":0.5,"centerForce":0.3,"linkDistance":30,"fontSize":0.6,"opacityScale":1,"showTags":true,"removeTags":[]}"></div></div></div><div class="toc desktop-only"><button type="button" id="toc" class><h3>Table of Contents</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"><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 class="depth-1"><a href="#编辑" data-for="编辑">编辑</a></li><li class="depth-1"><a href="#<23><>
|
|||
|
function toggleCallout() {
|
|||
|
const outerBlock = this.parentElement;
|
|||
|
outerBlock.classList.toggle(`is-collapsed`);
|
|||
|
const collapsed = outerBlock.classList.contains(`is-collapsed`);
|
|||
|
const height = collapsed ? this.scrollHeight : outerBlock.scrollHeight;
|
|||
|
outerBlock.style.maxHeight = height + `px`;
|
|||
|
let current = outerBlock;
|
|||
|
let parent = outerBlock.parentElement;
|
|||
|
while (parent) {
|
|||
|
if (!parent.classList.contains(`callout`)) {
|
|||
|
return;
|
|||
|
}
|
|||
|
const collapsed2 = parent.classList.contains(`is-collapsed`);
|
|||
|
const height2 = collapsed2 ? parent.scrollHeight : parent.scrollHeight + current.scrollHeight;
|
|||
|
parent.style.maxHeight = height2 + `px`;
|
|||
|
current = parent;
|
|||
|
parent = parent.parentElement;
|
|||
|
}
|
|||
|
}
|
|||
|
function setupCallout() {
|
|||
|
const collapsible = document.getElementsByClassName(
|
|||
|
`callout is-collapsible`
|
|||
|
);
|
|||
|
for (const div of collapsible) {
|
|||
|
const title = div.firstElementChild;
|
|||
|
if (title) {
|
|||
|
title.removeEventListener(`click`, toggleCallout);
|
|||
|
title.addEventListener(`click`, toggleCallout);
|
|||
|
const collapsed = div.classList.contains(`is-collapsed`);
|
|||
|
const height = collapsed ? title.scrollHeight : div.scrollHeight;
|
|||
|
div.style.maxHeight = height + `px`;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
document.addEventListener(`nav`, setupCallout);
|
|||
|
window.addEventListener(`resize`, setupCallout);
|
|||
|
</script><script type="module">
|
|||
|
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.esm.min.mjs';
|
|||
|
const darkMode = document.documentElement.getAttribute('saved-theme') === 'dark'
|
|||
|
mermaid.initialize({
|
|||
|
startOnLoad: false,
|
|||
|
securityLevel: 'loose',
|
|||
|
theme: darkMode ? 'dark' : 'default'
|
|||
|
});
|
|||
|
document.addEventListener('nav', async () => {
|
|||
|
await mermaid.run({
|
|||
|
querySelector: '.mermaid'
|
|||
|
})
|
|||
|
});
|
|||
|
</script><script src="https://cdn.jsdelivr.net/npm/katex@0.16.7/dist/contrib/copy-tex.min.js" type="application/javascript"></script><script src="../../../../postscript.js" type="module"></script></html>
|