693 lines
498 KiB
HTML
693 lines
498 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 配置文件 vimrc 的管理,包括不同操作系统下的 vimrc 文件位置、基本结构、示例配置及插件管理。."/><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 配置文件 vimrc 的管理,包括不同操作系统下的 vimrc 文件位置、基本结构、示例配置及插件管理。."/><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/2.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,
|
|||
|
<h3 id="位置">位置<a aria-hidden="true" tabindex="-1" href="#位置" class="internal"> §</a></h3>
|
|||
|
<p><code>vimrc</code> 文件是 Vim 的配置文件,用于存储用户的个人设置和定制。它的位置可能因操作系统而异:</p>
|
|||
|
<ul>
|
|||
|
<li><strong>Linux/Unix</strong>:通常在 <code>~/.vimrc</code> 或 <code>~/.vim/vimrc</code></li>
|
|||
|
<li><strong>MacOS</strong>:类似于 Linux,通常在 <code>~/.vimrc</code> 或 <code>~/.vim/vimrc</code></li>
|
|||
|
<li><strong>Windows</strong>:在 <code>C:\Users\<用户名>\_vimrc</code> 或 <code>C:\Users\<用户名>\vimfiles\vimrc</code></li>
|
|||
|
</ul>
|
|||
|
<p>在 Vim 中,可以通过以下命令查看 <code>vimrc</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 style="color:var(--shiki-token-function);">echo</span><span style="color:var(--shiki-color-text);"> $MYVIMRC</span></span></code></pre></div>
|
|||
|
<h3 id="基本结构">基本结构<a aria-hidden="true" tabindex="-1" href="#基本结构" class="internal"> §</a></h3>
|
|||
|
<p>一个典型的 <code>vimrc</code> 文件可能包含以下几部分:</p>
|
|||
|
<ol>
|
|||
|
<li><strong>全局设置</strong>:设置 Vim 的全局行为,例如编码、文件格式等。</li>
|
|||
|
<li><strong>界面设置</strong>:配置界面元素,例如行号、颜色主题、状态栏等。</li>
|
|||
|
<li><strong>编辑设置</strong>:调整编辑行为,例如自动缩进、搜索选项等。</li>
|
|||
|
<li><strong>插件设置</strong>:加载和配置 Vim 插件。</li>
|
|||
|
<li><strong>快捷键映射</strong>:自定义快捷键,提升编辑效率。</li>
|
|||
|
</ol>
|
|||
|
<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-token-comment);">" 全局设置</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">nocompatible</span><span style="color:var(--shiki-token-comment);"> " 关闭与 Vi 的兼容模式</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-constant);">filetype</span><span style="color:var(--shiki-color-text);"> off</span><span style="color:var(--shiki-token-comment);"> " 关闭文件类型检测</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 界面设置</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">number</span><span style="color:var(--shiki-token-comment);"> " 显示行号</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">syntax on</span><span style="color:var(--shiki-token-comment);"> " 启用语法高亮</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">background</span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-color-text);">dark</span><span style="color:var(--shiki-token-comment);"> " 设置背景色为暗色系</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">colorscheme desert</span><span style="color:var(--shiki-token-comment);"> " 使用 desert 颜色主题</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 编辑设置</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">tabstop</span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-token-constant);">4</span><span style="color:var(--shiki-token-comment);"> " 设置 Tab 宽度为 4 个空格</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">shiftwidth</span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-token-constant);">4</span><span style="color:var(--shiki-token-comment);"> " 设置自动缩进的宽度为 4 个空格</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">expandtab</span><span style="color:var(--shiki-token-comment);"> " 将 Tab 转换为空格</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">autoindent</span><span style="color:var(--shiki-token-comment);"> " 自动缩进新行</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">hlsearch</span><span style="color:var(--shiki-token-comment);"> " 高亮搜索结果</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">incsearch</span><span style="color:var(--shiki-token-comment);"> " 增量搜索</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 插件设置</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">call </span><span style="color:var(--shiki-token-function);">plug#begin</span><span style="color:var(--shiki-color-text);">(</span><span style="color:var(--shiki-token-string-expression);">'~/.vim/plugged'</span><span style="color:var(--shiki-color-text);">)</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'scrooloose/nerdtree'</span><span style="color:var(--shiki-token-comment);"> " 文件树插件</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'tpope/vim-fugitive'</span><span style="color:var(--shiki-token-comment);"> " Git 集成插件</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">call </span><span style="color:var(--shiki-token-function);">plug#end</span><span style="color:var(--shiki-color-text);">()</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 快捷键映射</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <C-n> :NERDTreeToggle<CR></span><span style="color:var(--shiki-token-comment);"> " Ctrl+n 切换 NERDTree</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><th>示例</th></tr></thead><tbody><tr><td><code>set nocompatible</code></td><td>关闭与 Vi 的兼容模式</td><td><code>set nocompatible</code></td></tr><tr><td><code>set number</code></td><td>显示行号</td><td><code>set number</code></td></tr><tr><td><code>set relativenumber</code></td><td>显示相对行号</td><td><code>set relativenumber</code></td></tr><tr><td><code>set tabstop</code></td><td>设置 Tab 宽度(以空格数表示)</td><td><code>set tabstop=4</code></td></tr><tr><td><code>set shiftwidth</code></td><td>设置自动缩进的宽度(以空格数表示)</td><td><code>set shiftwidth=4</code></td></tr><tr><td><code>set expandtab</code></td><td>将 Tab 转换为空格</td><td><code>set expandtab</code></td></tr><tr><td><code>set autoindent</code></td><td>自动缩进新行</td><td><code>set autoindent</code></td></tr><tr><td><code>set smartindent</code></td><td>智能缩进</td><td><code>set smartindent</code></td></tr><tr><td><code>set hlsearch</code></td><td>高亮搜索结果</td><td><code>set hlsearch</code></td></tr><tr><td><code>set incsearch</code></td><td>增量搜索</td><td><code>set incsearch</code></td></tr><tr><td><code>set ignorecase</code></td><td>搜索时忽略大小写</td><td><code>set ignorecase</code></td></tr><tr><td><code>set smartcase</code></td><td>智能大小写匹配</td><td><code>set smartcase</code></td></tr><tr><td><code>syntax on</code></td><td>启用语法高亮</td><td><code>syntax on</code></td></tr><tr><td><code>set background</code></td><td>设置背景色(dark 或 light)</td><td><code>set background=dark</code></td></tr><tr><td><code>colorscheme</code></td><td>设置颜色主题</td><td><code>colorscheme desert</code></td></tr><tr><td><code>set cursorline</code></td><td>高亮当前行</td><td><code>set cursorline</code></td></tr><tr><td><code>set wrap</code></td><td>自动换行显示长行</td><td><code>set wrap</code></td></tr><tr><td><code>set nowrap</code></td><td>禁止自动换行显示长行</td><td><code>set nowrap</code></td></tr><tr><td><code>set linebreak</code></td><td>在单词边界处换行</td><td><code>set linebreak</code></td></tr><tr><td><code>set showcmd</code></td><td>显示部分命令(在底部命令行显示)</td><td><code>set showcmd</code></td></tr><tr><td><code>set ruler</code></td><td>显示光标位置(行号和列号)</td><td><code>set ruler</code></td></tr><tr><td><code>set wildmenu</code></td><td>命令行补全增强</td><td><code>set wildmenu</code></td></tr><tr><td><code>set clipboard</code></td><td>使用系统剪贴板</td><td><code>set clipboard=unnamedplus</code></td></tr><tr><td><code>set backspace</code></td><td>设置退格键的行为</td><td><code>set backspace=indent,eol,start</code></td></tr><tr><td><code>set mouse</code></td><td>启用鼠标操作(a 为全部模式启用)</td><td><code>set mouse=a</code></td></tr><tr><td><code>set splitbelow</code></td><td>新窗口在当前窗口下方打开</td><td><code>set splitbelow</code></td></tr><tr><td><code>set splitright</code></td><td>新窗口在当前窗口右侧打开</td><td><code>set splitright</code></td></tr><tr><td><code>set foldmethod</code></td><td>设置折叠方法(syntax、indent 等)</td><td><code>set foldmethod=syntax</code></td></tr><tr><td><code>set foldlevel</code></td><td>设置折叠级别</td><td><code>set foldlevel=99</code></td></tr><tr><td><code>set termguicolors</code></td><td>启用真彩色支持(需要终端支持)</td><td><code>set termguicolors</code></td></tr><tr><td><code>set guifont</code></td><td>设置 GUI 字体(在 GUI Vim 中使用)</td><td><code>set guifont=Monaco:h12</code></td></tr><tr><td><code>set encoding</code></td><td>设置文件编码</td><td><code>set encoding=utf-8</code></td></tr><tr><td><code>filetype plugin indent on</code></td><td>启用文件类型检测和插件</td><td><code>filetype plugin indent on</code></td></tr><tr><td><code>set spell</code></td><td>启用拼写检查</td><td><code>set spell</code></td></tr><tr><td><code>s
|
|||
|
<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>
|
|||
|
<p>Vim 提供了强大的快捷键映射功能,用户可以根据需要自定义快捷键。常用的映射命令有:</p>
|
|||
|
<ul>
|
|||
|
<li><code>map</code>:通用映射</li>
|
|||
|
<li><code>nmap</code>:普通模式下的映射</li>
|
|||
|
<li><code>imap</code>:插入模式下的映射</li>
|
|||
|
<li><code>vmap</code>:可视模式下的映射</li>
|
|||
|
</ul>
|
|||
|
<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-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <C-s> :w<CR></span><span style="color:var(--shiki-token-comment);"> " 在普通模式下,Ctrl+s 保存文件</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">inoremap</span><span style="color:var(--shiki-color-text);"> <C-c> <Esc></span><span style="color:var(--shiki-token-comment);"> " 在插入模式下,Ctrl+c 切换到普通模式</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">vnoremap</span><span style="color:var(--shiki-color-text);"> <C-c> </span><span style="color:var(--shiki-token-string-expression);">"+y "</span><span style="color:var(--shiki-color-text);"> 在可视模式下,Ctrl</span><span style="color:var(--shiki-token-keyword);">+</span><span style="color:var(--shiki-color-text);">c 复制到系统剪贴板</span></span></code></pre></div>
|
|||
|
<h3 id="常用快捷键示例">常用快捷键示例<a aria-hidden="true" tabindex="-1" href="#常用快捷键示例" class="internal"> §</a></h3>
|
|||
|
<p>以下是一些常用的快捷键示例,这些快捷键可以提高日常编辑的效率:</p>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>快捷键配置</th><th>模式</th><th>说明</th><th>示例</th></tr></thead><tbody><tr><td><code>nnoremap <C-s> :w<CR></code></td><td>普通模式</td><td><code>Ctrl+s</code> 保存文件</td><td><code>nnoremap <C-s> :w<CR></code></td></tr><tr><td><code>inoremap <C-c> <Esc></code></td><td>插入模式</td><td><code>Ctrl+c</code> 退出插入模式</td><td><code>inoremap <C-c> <Esc></code></td></tr><tr><td><code>vnoremap <C-c> "+y</code></td><td>可视模式</td><td><code>Ctrl+c</code> 复制到系统剪贴板</td><td><code>vnoremap <C-c> "+y</code></td></tr><tr><td><code>nnoremap <C-x> :q<CR></code></td><td>普通模式</td><td><code>Ctrl+x</code> 退出 Vim</td><td><code>nnoremap <C-x> :q<CR></code></td></tr><tr><td><code>nnoremap <C-t> :tabnew<CR></code></td><td>普通模式</td><td><code>Ctrl+t</code> 打开新标签</td><td><code>nnoremap <C-t> :tabnew<CR></code></td></tr><tr><td><code>nnoremap <C-n> :NERDTreeToggle<CR></code></td><td>普通模式</td><td><code>Ctrl+n</code> 切换 NERDTree 文件树</td><td><code>nnoremap <C-n> :NERDTreeToggle<CR></code></td></tr><tr><td><code>nnoremap <Leader>f :Files<CR></code></td><td>普通模式</td><td><code>Leader+f</code> 调用 FZF 查找文件</td><td><code>nnoremap <Leader>f :Files<CR></code></td></tr><tr><td><code>nnoremap <Leader>g :Gstatus<CR></code></td><td>普通模式</td><td><code>Leader+g</code> 调用 Git 状态</td><td><code>nnoremap <Leader>g :Gstatus<CR></code></td></tr><tr><td><code>nnoremap <Leader>w :w!<CR></code></td><td>普通模式</td><td><code>Leader+w</code> 强制保存文件</td><td><code>nnoremap <Leader>w :w!<CR></code></td></tr><tr><td><code>nnoremap <Leader>q :q!<CR></code></td><td>普通模式</td><td><code>Leader+q</code> 强制退出 Vim</td><td><code>nnoremap <Leader>q :q!<CR></code></td></tr><tr><td><code>nnoremap <Leader>r :source $MYVIMRC<CR></code></td><td>普通模式</td><td><code>Leader+r</code> 重新加载 <code>vimrc</code> 文件</td><td><code>nnoremap <Leader>r :source $MYVIMRC<CR></code></td></tr><tr><td><code>vnoremap <Leader>y "+y</code></td><td>可视模式</td><td><code>Leader+y</code> 复制选中文本到系统剪贴板</td><td><code>vnoremap <Leader>y "+y</code></td></tr><tr><td><code>nnoremap <Leader>p "+p</code></td><td>普通模式</td><td><code>Leader+p</code> 从系统剪贴板粘贴</td><td><code>nnoremap <Leader>p "+p</code></td></tr><tr><td><code>nnoremap <Leader>t :terminal<CR></code></td><td>普通模式</td><td><code>Leader+t</code> 打开终端</td><td><code>nnoremap <Leader>t :terminal<CR></code></td></tr><tr><td><code>nnoremap <C-j> :cnext<CR></code></td><td>普通模式</td><td><code>Ctrl+j</code> 跳到下一个 QuickFix 项</td><td><code>nnoremap <C-j> :cnext<CR></code></td></tr><tr><td><code>nnoremap <C-k> :cprev<CR></code></td><td>普通模式</td><td><code>Ctrl+k</code> 跳到上一个 QuickFix 项</td><td><code>nnoremap <C-k> :cprev<CR></code></td></tr><tr><td><code>nnoremap <Leader>n :nohlsearch<CR></code></td><td>普通模式</td><td><code>Leader+n</code> 取消搜索高亮</td><td><code>nnoremap <Leader>n :nohlsearch<CR></code></td></tr><tr><td><code>nnoremap <Leader>e :e ~/.vimrc<CR></code></td><td>普通模式</td><td><code>Leader+e</code> 打开 <code>vimrc</code> 文件</td><td><code>nnoremap <Leader>e :e ~/.vimrc<CR></code></td></tr><tr><td><code>nnoremap <Leader>d "_d</code></td><td>普通模式</td><td><code>Leader+d</code> 删除但不复制到寄存器</td><td><code>nnoremap <Leader>d "_d</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>
|
|||
|
<h4 id="vundle">Vundle<a aria-hidden="true" tabindex="-1" href="#vundle" class="internal"> §</a></h4>
|
|||
|
<p><a href="https://github.com/VundleVim/Vundle.vim" class="external">Vundle</a> 是一个流行的 Vim 插件管理工具,安装步骤如下:</p>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p>克隆 Vundle 仓库到 Vim 的插件目录:</p>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="shell" data-theme="default"><code data-language="shell" data-theme="default"><span data-line><span style="color:var(--shiki-token-function);">$</span><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-string);">git</span><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-string);">clone</span><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-string);">https://github.com/VundleVim/Vundle.vim.git</span><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-string);">~/.vim/bundle/Vundle.vim</span></span></code></pre></div>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p>在 <code>vimrc</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);">set </span><span style="color:var(--shiki-token-constant);">nocompatible</span><span style="color:var(--shiki-token-comment);"> " 关闭 Vi 兼容模式</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-constant);">filetype</span><span style="color:var(--shiki-color-text);"> off</span><span style="color:var(--shiki-token-comment);"> " 关闭文件类型检测</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 设置 Vundle</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">rtp</span><span style="color:var(--shiki-token-keyword);">+=~</span><span style="color:var(--shiki-token-string-expression);">/.vim/</span><span style="color:var(--shiki-color-text);">bundle/Vundle.vim</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">call </span><span style="color:var(--shiki-token-function);">vundle#begin</span><span style="color:var(--shiki-color-text);">()</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 在此处添加插件</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plugin </span><span style="color:var(--shiki-token-string-expression);">'VundleVim/Vundle.vim'</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">call </span><span style="color:var(--shiki-token-function);">vundle#end</span><span style="color:var(--shiki-color-text);">()</span><span style="color:var(--shiki-token-comment);"> " 所有插件必须在这一行之前</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-constant);">filetype</span><span style="color:var(--shiki-color-text);"> plugin indent on</span><span style="color:var(--shiki-token-comment);"> " 启用文件类型检测</span></span></code></pre></div>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<p><strong>基本使用</strong>:</p>
|
|||
|
<ul>
|
|||
|
<li>安装插件: 在 <code>vimrc</code> 中添加插件后,启动 Vim 并运行 <code>:PluginInstall</code>。</li>
|
|||
|
<li>更新插件: 启动 Vim 并运行 <code>:PluginUpdate</code>。</li>
|
|||
|
<li>删除插件: 从 <code>vimrc</code> 中移除插件行,启动 Vim 并运行 <code>:PluginClean</code>。</li>
|
|||
|
</ul>
|
|||
|
<h4 id="vim-plug">Vim-plug<a aria-hidden="true" tabindex="-1" href="#vim-plug" class="internal"> §</a></h4>
|
|||
|
<p><a href="https://github.com/junegunn/vim-plug" class="external">vim-plug</a> 是一个现代的 Vim 插件管理工具,安装步骤如下:</p>
|
|||
|
<ol>
|
|||
|
<li>
|
|||
|
<p>下载 vim-plug 并放入 <code>autoload</code> 目录:</p>
|
|||
|
<div data-rehype-pretty-code-fragment><pre style="background-color:var(--shiki-color-background);" tabindex="0" data-language="shell" data-theme="default"><code data-language="shell" data-theme="default"><span data-line><span style="color:var(--shiki-token-function);">$</span><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-string);">curl</span><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-string);">-fLo</span><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-string);">~/.vim/autoload/plug.vim</span><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-string);">--create-dirs</span><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-string);">https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim</span></span></code></pre></div>
|
|||
|
</li>
|
|||
|
<li>
|
|||
|
<p>在 <code>vimrc</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);">call </span><span style="color:var(--shiki-token-function);">plug#begin</span><span style="color:var(--shiki-color-text);">(</span><span style="color:var(--shiki-token-string-expression);">'~/.vim/plugged'</span><span style="color:var(--shiki-color-text);">)</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 在此处添加插件</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'junegunn/vim-plug'</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">call </span><span style="color:var(--shiki-token-function);">plug#end</span><span style="color:var(--shiki-color-text);">()</span></span></code></pre></div>
|
|||
|
</li>
|
|||
|
</ol>
|
|||
|
<p><strong>基本使用</strong>:</p>
|
|||
|
<ul>
|
|||
|
<li>安装插件: 在 <code>vimrc</code> 中添加插件后,启动 Vim 并运行 <code>:PlugInstall</code>。</li>
|
|||
|
<li>更新插件: 启动 Vim 并运行 <code>:PlugUpdate</code>。</li>
|
|||
|
<li>删除插件: 从 <code>vimrc</code> 中移除插件行,启动 Vim 并运行 <code>:PlugClean</code>。</li>
|
|||
|
</ul>
|
|||
|
<h3 id="常用插件">常用插件<a aria-hidden="true" tabindex="-1" href="#常用插件" class="internal"> §</a></h3>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<table><thead><tr><th>插件</th><th>功能描述</th><th>安装配置示例(基于 vim-plug)</th><th>常用命令或快捷键</th></tr></thead><tbody><tr><td>NERDTree</td><td>文件树管理</td><td><code>Plug 'preservim/nerdtree'</code></td><td><code>:NERDTreeToggle</code></td></tr><tr><td>fzf.vim</td><td>模糊查找</td><td><code>Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }</code></td><td><code>:Files</code> <code>:Buffers</code></td></tr><tr><td>ctrlp.vim</td><td>文件和缓冲区切换</td><td><code>Plug 'ctrlpvim/ctrlp.vim'</code></td><td><code>:CtrlP</code></td></tr><tr><td>YouCompleteMe</td><td>代码补全</td><td><code>Plug 'ycm-core/YouCompleteMe'</code> (需要编译安装)</td><td>自动代码补全</td></tr><tr><td>Syntastic</td><td>语法检查</td><td><code>Plug 'vim-syntastic/syntastic'</code></td><td><code>:SyntasticCheck</code></td></tr><tr><td>vim-airline</td><td>状态栏美化</td><td><code>Plug 'vim-airline/vim-airline'</code> <code>Plug 'vim-airline/vim-airline-themes'</code></td><td>自动启用状态栏美化</td></tr><tr><td>vim-fugitive</td><td>Git 集成</td><td><code>Plug 'tpope/vim-fugitive'</code></td><td><code>:Gstatus</code> <code>:Gcommit</code> <code>:Gpush</code> <code>:Gpull</code></td></tr><tr><td>vim-surround</td><td>快速修改括号、引号等符号</td><td><code>Plug 'tpope/vim-surround'</code></td><td><code>ysiw]</code> <code>ds'</code> <code>cs"'</code></td></tr><tr><td>vim-commentary</td><td>快速注释代码</td><td><code>Plug 'tpope/vim-commentary'</code></td><td><code>gc</code> + 动作</td></tr><tr><td>vim-gitgutter</td><td>显示 Git 更改信息</td><td><code>Plug 'airblade/vim-gitgutter'</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);">call </span><span style="color:var(--shiki-token-function);">plug#begin</span><span style="color:var(--shiki-color-text);">(</span><span style="color:var(--shiki-token-string-expression);">'~/.vim/plugged'</span><span style="color:var(--shiki-color-text);">)</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 文件树管理</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'preservim/nerdtree'</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 模糊查找</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'junegunn/fzf'</span><span style="color:var(--shiki-color-text);">, { </span><span style="color:var(--shiki-token-string-expression);">'do'</span><span style="color:var(--shiki-color-text);">: { -> </span><span style="color:var(--shiki-token-function);">fzf#install</span><span style="color:var(--shiki-color-text);">() } }</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'junegunn/fzf.vim'</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 文件和缓冲区切换</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'ctrlpvim/ctrlp.vim'</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 状态栏美化</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'vim-airline/vim-airline'</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'vim-airline/vim-airline-themes'</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" Git 集成</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'tpope/vim-fugitive'</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 快速修改括号、引号等符号</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'tpope/vim-surround'</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 快速注释代码</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'tpope/vim-commentary'</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 显示 Git 更改信息</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">Plug </span><span style="color:var(--shiki-token-string-expression);">'airblade/vim-gitgutter'</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">call </span><span style="color:var(--shiki-token-function);">plug#end</span><span style="color:var(--shiki-color-text);">()</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 基本设置</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">nocompatible</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">number</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">relativenumber</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">tabstop</span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-token-constant);">4</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">shiftwidth</span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-token-constant);">4</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">expandtab</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">autoindent</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">hlsearch</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">incsearch</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">ignorecase</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">smartcase</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">syntax on</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">background</span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-color-text);">dark</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">colorscheme desert</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">cursorline</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">wrap</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">showcmd</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">ruler</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">wildmenu</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">clipboard</span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-color-text);">unnamedplus</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">backspace</span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-color-text);">indent,</span><span style="color:var(--shiki-token-constant);">eol</span><span style="color:var(--shiki-color-text);">,start</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">mouse</span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-color-text);">a</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">splitbelow</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">splitright</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">foldmethod</span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-token-constant);">syntax</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">foldlevel</span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-token-constant);">99</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">set </span><span style="color:var(--shiki-token-constant);">termguicolors</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" 快捷键映射</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <C-n> :NERDTreeToggle<CR></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <C-p> :CtrlP<CR></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <Leader>f :Files<CR></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <Leader>g :Gstatus<CR></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <Leader>w :w</span><span style="color:var(--shiki-token-keyword);">!</span><span style="color:var(--shiki-color-text);"><CR></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <Leader>q :q</span><span style="color:var(--shiki-token-keyword);">!</span><span style="color:var(--shiki-color-text);"><CR></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <Leader>r :</span><span style="color:var(--shiki-token-function);">source</span><span style="color:var(--shiki-color-text);"> $MYVIMRC<CR></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">vnoremap</span><span style="color:var(--shiki-color-text);"> <Leader>y </span><span style="color:var(--shiki-token-string-expression);">"+y</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <Leader>p </span><span style="color:var(--shiki-token-string-expression);">"+p</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <Leader>t :terminal<CR></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <C-j> :cnext<CR></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <C-k> :cprev<CR></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <Leader>n :</span><span style="color:var(--shiki-token-constant);">nohlsearch</span><span style="color:var(--shiki-color-text);"><CR></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <Leader>e :e </span><span style="color:var(--shiki-token-keyword);">~</span><span style="color:var(--shiki-color-text);">/.vimrc<CR></span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-keyword);">nnoremap</span><span style="color:var(--shiki-color-text);"> <Leader>d </span><span style="color:var(--shiki-token-string-expression);">"_d</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" Airline 主题</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">let g:airline_theme</span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-token-string-expression);">'luna'</span></span>
|
|||
|
<span data-line> </span>
|
|||
|
<span data-line><span style="color:var(--shiki-token-comment);">" GitGutter 配置</span></span>
|
|||
|
<span data-line><span style="color:var(--shiki-color-text);">let g:gitgutter_enabled </span><span style="color:var(--shiki-token-keyword);">=</span><span style="color:var(--shiki-color-text);"> </span><span style="color:var(--shiki-token-constant);">1</span></span>
|
|||
|
<span data-line> </span></code></pre></div></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="#vimrc-文件" data-for="vimrc-文件">vimrc 文件</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="#快捷键映射" 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></ul></div></div><div class="backlinks "><h3>Backlinks</h3><ul class="overflow"><li>No backlinks found</li></ul></div><div class="explorer mobile-only"><button type="button" id="explorer" data-behavior="collapse" data-collapsed="collapsed" data-savestate="true" data-tree="[{"path":"Journal","collapsed":true},{"path":"Journal/2024","collapsed":true},{"path":"Journal/2024/W33","collapsed":true},{"path":"Obsidian","collapsed":true},{"path":"Obsidian/Templates","collapsed":true},{"path":"Personal","collapsed":true},{"path":"Personal/Blog","collapsed":true},{"path":"Personal/Blog/2018","collapsed":true},{"path":"Personal/Blog/2020","collapsed":true},{"path":"Personal/Blog/2021","collapsed":true},{"path":"Personal/Blog/2022","collapsed":true},{"path":"Personal/Blog/2023","collapsed":true},{"path":"Personal/Blog/2024","collapsed":true},{"path":"Personal/Book","collapsed":true},{"path":"Personal/Book/个人成长","collapsed":true},{"path":"Personal/Book/医学健康","collapsed":true},{"path":"Personal/Book/历史","collapsed":true},{"path":"Personal/Book/哲学宗教","collapsed":true},{"path":"Personal/Book/心理","collapsed":true},{"path":"Personal/Book/政治军事","collapsed":true},{"path":"Personal/Book/教育学习","collapsed":true},{"path":"Personal/Book/文学","collapsed":true},{"path":"Personal/Book/生活百科","collapsed":true},{&q
|
|||
|
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>
|