mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 04:58:21 +00:00
34 lines
18 KiB
HTML
34 lines
18 KiB
HTML
|
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>Vim</title><script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async="" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script><script type="text/x-mathjax-config">
|
||
|
MathJax = {
|
||
|
tex: {
|
||
|
inlineMath: [ ['$','$'], ['\(','\)'] ],
|
||
|
displayMath: [ ['$$','$$'], ['[',']'] ]
|
||
|
},
|
||
|
options = {
|
||
|
processHtmlClass = "math"
|
||
|
}
|
||
|
}
|
||
|
</script><meta name="next-head-count" content="6"/><link rel="preload" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" as="style"/><link rel="stylesheet" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" data-n-g=""/><noscript data-n-css=""></noscript><link rel="preload" href="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" as="script"/></head><body><div id="__next"><main><h1>Vim</h1><section class="post-metadata"><span>Date: <!-- -->2021-06-06 05:12:20 +08:00</span><span>Date modified: <!-- -->2021-07-20 23:31:58 +08:00</span></section><nav class="toc"><ol class="toc-level toc-level-1"><li class="toc-item toc-item-h1"><a href="/wiki/editor.vim#the-keybindings-of-vim" class="toc-link toc-link-h1">The keybindings of Vim</a></li><li class="toc-item toc-item-h1"><a href="/wiki/editor.vim#tips-and-tricks" class="toc-link toc-link-h1">Tips and tricks</a></li></ol></nav><p>Every sysadmin's favorite default text editor.
|
||
|
Is being familiar to Vim a path to productivity?
|
||
|
No.
|
||
|
But being good at it can make for a difference in the day-to-day life of a sysadmin for there are advanced capabilities of this editor.
|
||
|
</p><h1 id="the-keybindings-of-vim">The keybindings of Vim</h1><p>One of the things that make Vim popular is the keybindings.
|
||
|
</p><table><thead><tr><th>Keybinding</th><th>Description</th></tr></thead><tbody><tr><td><code class="inline-verbatim">[m</code></td><td>Go to the previous method.</td></tr><tr><td><code class="inline-verbatim">g~w</code></td><td>Toggle letter casing.</td></tr><tr><td><code class="inline-verbatim">2guW</code></td><td>Convert two words into lowercase.</td></tr><tr><td><code class="inline-verbatim">10d)</code></td><td>Delete 10 sentences.</td></tr><tr><td><code class="inline-verbatim">39zz</code></td><td>Place the cursor in the middle in line 39.</td></tr><tr><td><code class="inline-verbatim">3d10w</code></td><td>Delete 10 words and repeat 3 times.</td></tr></tbody></table><p>Most of the time, Vim keybindings is made of mainly two things:
|
||
|
</p><ul><li><p><strong>The operators denoting an action.</strong></p></li><li><p><strong>The motions describing the scope of the action.</strong></p></li></ul><p>There's a certain pattern to it when you use it, too.
|
||
|
</p><pre class="src-block"><code>[count][operator][motion]
|
||
|
</code></pre><h1 id="tips-and-tricks">Tips and tricks</h1><ul><li><p><code class="inline-verbatim">:h</code> is the help system of Vim.
|
||
|
It contains all of the documentation of the editor and the installed plugins.
|
||
|
I recommend to start with the default help page (e.g., <code class="inline-verbatim">:h</code>).
|
||
|
</p><ul><li><p>You can get the meaning of the keybinding with the help section — e.g., <code class="inline-code">:h gg</code>, <code class="inline-code">:h G</code>.
|
||
|
</p></li></ul></li><li><p>Vim has fine-grained control motions.
|
||
|
</p><ul><li><p><code class="inline-verbatim">(</code> and <code class="inline-verbatim">)</code> for sentences.
|
||
|
</p></li><li><p><code class="inline-verbatim">{</code> and <code class="inline-verbatim">}</code> for paragraphs.
|
||
|
</p></li><li><p><code class="inline-verbatim">[</code> and <code class="inline-verbatim">]</code> for sections.
|
||
|
</p></li></ul></li><li><p>There are many advanced navigation features in Vim.
|
||
|
</p><ul><li><p><code class="inline-verbatim">gf</code> will go to the file at point.
|
||
|
</p></li><li><p><code class="inline-verbatim">K</code> goes to the definition of the keyword at point.
|
||
|
</p></li><li><p><code class="inline-verbatim">Ctrl+O</code> will jump back at a previous jump point.
|
||
|
</p></li><li><p><code class="inline-verbatim">gd</code> go the local definition of the keyword at point.
|
||
|
</p></li><li><p><code class="inline-verbatim">H</code>, <code class="inline-verbatim">M</code>, and <code class="inline-verbatim">L</code> places the cursor in higher, middle, and lower part in the current screen, respectively.
|
||
|
</p></li><li><p><code class="inline-verbatim">zt</code>, <code class="inline-verbatim">zz</code>, and <code class="inline-verbatim">zb</code> displays the current line in the top, middle, and bottom part of the screen, respectively.
|
||
|
</p></li></ul></li></ul></main></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"metadata":{"date":"\"2021-06-06 05:12:20 +08:00\"","date_modified":"\"2021-07-20 23:31:58 +08:00\"","language":"en","source":""},"title":"Vim","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"the-keybindings-of-vim"},"children":[{"type":"text","value":"The keybindings of Vim"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/editor.vim#the-keybindings-of-vim"},"children":[{"type":"text","value":"The keybindings of Vim"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"tips-and-tricks"},"children":[{"type":"text","value":"Tips and tricks"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/editor.vim#tips-and-tricks"},"children":[{"type":"text","value":"Tips and tricks"}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"Every sysadmin's favorite default text editor.\nIs being familiar to Vim a path to productivity?\nNo.\nBut being good at it can make for a difference in the day-to-day life of a sysadmin for there are advanced capabilities of this editor.\n"}]},{"type":"element","tagName":"h1","properties":{"id":"the-keybindings-of-vim"},"children":[{"type":"text","value":"The keybindings of Vim"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"One of the things that make Vim popular is the keybindings.\n"}]},{"type":"element","tagName":"table","properties":{},"children":[{"type":"element","tagName":"thead","properties":{},"children":[{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Keybinding"}]},{"type":"element","tagName":"th","properties":{},"children":[{"type":"text","value":"Description"}]}]}]},{"type":"element","tagName":"tbody","properties":{},"children":[{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"[m"}]}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Go to the previous method."}]}]},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"g~w"}]}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Toggle letter casing."}]}]},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"2guW"}]}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Convert two words into lowercase."}]}]},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"children":[{"type":"text","value":"10d)"}]}]},{"type":"element","tagName":"td","properties":{},"children":[{"type":"text","value":"Delete 10 sentences."}]}]},{"type":"element","tagName":"tr","properties":{},"children":[{"type":"element","tagName":"td","properties":{},"children":[{"type":"element","tagName":"code","properties":{"className":["inline-verbatim"]},"child
|