2023-05-02 17:42:11 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8" />
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
|
|
<link
|
|
|
|
rel="stylesheet"
|
|
|
|
href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.2.0/github-markdown-dark.min.css"
|
|
|
|
/>
|
|
|
|
<title>haunt98 posts</title>
|
|
|
|
</head>
|
|
|
|
<style>
|
|
|
|
.markdown-body {
|
|
|
|
box-sizing: border-box;
|
|
|
|
min-width: 200px;
|
|
|
|
max-width: 980px;
|
|
|
|
margin: 0 auto;
|
|
|
|
padding: 45px;
|
|
|
|
}
|
|
|
|
|
|
|
|
@media (max-width: 767px) {
|
|
|
|
.markdown-body {
|
|
|
|
padding: 15px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
<body class="markdown-body">
|
|
|
|
<div><a href="index.html">Index</a></div>
|
|
|
|
<h1>
|
|
|
|
<a
|
|
|
|
id="user-content-my-neovim-workflow"
|
|
|
|
class="anchor"
|
|
|
|
aria-hidden="true"
|
|
|
|
href="#my-neovim-workflow"
|
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span></a
|
|
|
|
>My neovim workflow
|
|
|
|
</h1>
|
2023-06-10 04:57:15 +00:00
|
|
|
<p>
|
|
|
|
<a
|
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer nofollow"
|
|
|
|
href="https://raw.githubusercontent.com/haunt98/posts-images/main/nvim-000.png"
|
|
|
|
><img
|
|
|
|
src="https://raw.githubusercontent.com/haunt98/posts-images/main/nvim-000.png"
|
|
|
|
alt="nvim-000"
|
|
|
|
style="max-width: 100%"
|
|
|
|
/></a>
|
|
|
|
</p>
|
2023-06-10 03:50:39 +00:00
|
|
|
<p>
|
|
|
|
All configs are in
|
|
|
|
<a href="https://github.com/haunt98/dotfiles">my dotfiles</a>.
|
|
|
|
</p>
|
2023-05-02 17:42:11 +00:00
|
|
|
<p>Search multiple words:</p>
|
2023-06-10 03:50:39 +00:00
|
|
|
<div class="highlight highlight-source-viml">
|
|
|
|
<pre>:/<span class="pl-cce">\v</span>word1|word2|word3</pre>
|
2023-05-02 17:42:11 +00:00
|
|
|
</div>
|
2023-06-10 03:50:39 +00:00
|
|
|
<p>Replace word:</p>
|
|
|
|
<div class="highlight highlight-source-viml">
|
|
|
|
<pre>:<span class="pl-k">%</span><span class="pl-c1">s</span><span class="pl-sr">/word1/</span>word2/<span class="pl-c1">g</span></pre>
|
|
|
|
</div>
|
2023-07-07 09:58:37 +00:00
|
|
|
<p>Delete all lines contain word:</p>
|
|
|
|
<div class="highlight highlight-source-viml">
|
|
|
|
<pre>:<span class="pl-c1">g</span><span class="pl-sr">/word/</span><span class="pl-c1">d</span></pre>
|
|
|
|
</div>
|
2023-06-10 03:50:39 +00:00
|
|
|
<p>Jump basic:</p>
|
|
|
|
<ul>
|
|
|
|
<li><code>gg</code>: first line</li>
|
|
|
|
<li><code>G</code>: last line</li>
|
|
|
|
<li><code>0</code>: first character of line</li>
|
|
|
|
<li><code>$</code>: last character of line</li>
|
|
|
|
<li><code>w</code>, <code>b</code>: word forward/backward</li>
|
2023-06-15 19:17:40 +00:00
|
|
|
<li><code>e</code>, <code>ge</code>: end of word current/before</li>
|
|
|
|
<li>
|
|
|
|
<code>W</code>, <code>B</code>: WORD (word with special char)
|
|
|
|
forward/backward
|
|
|
|
</li>
|
|
|
|
<li><code>E</code>, <code>gE</code>: end of WORD current/before</li>
|
2023-06-24 17:18:07 +00:00
|
|
|
<li>
|
|
|
|
<code>f{char}</code>, <code>F{char}</code>: find forward/backward
|
|
|
|
character
|
|
|
|
</li>
|
2023-06-10 03:50:39 +00:00
|
|
|
</ul>
|
|
|
|
<p>Jump advance:</p>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<code>CTRL-O</code>, <code>CTRL-I</code>: cursor position
|
|
|
|
backward/forward
|
|
|
|
</li>
|
|
|
|
<li><code>(</code>, <code>)</code>: sentence backward/forward</li>
|
|
|
|
<li><code>{</code>, <code>}</code>: paragraph backward/forward</li>
|
|
|
|
<li><code>H</code>: top of screen</li>
|
|
|
|
<li><code>M</code>: middle of screen</li>
|
|
|
|
<li><code>L</code>: bottom of screen</li>
|
|
|
|
<li>
|
|
|
|
<code>CTRL-]</code>, <code>CTRL-T</code>: jump to tag/jump back from tag
|
|
|
|
<ul>
|
|
|
|
<li>
|
2023-06-10 07:15:38 +00:00
|
|
|
Support jump to Go definition with
|
2023-06-10 03:50:39 +00:00
|
|
|
<a href="https://github.com/fatih/vim-go">fatih/vim-go</a>.
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2023-07-04 06:24:03 +00:00
|
|
|
<p>Use both <code>\</code> and <code>;</code> as leader key:</p>
|
2023-06-10 03:50:39 +00:00
|
|
|
<div class="highlight highlight-source-lua">
|
2023-07-04 06:24:03 +00:00
|
|
|
<pre>vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>;<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span><Leader><span class="pl-pds">"</span></span>, { remap <span class="pl-k">=</span> <span class="pl-c1">true</span> })
|
2023-07-07 06:49:38 +00:00
|
|
|
vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>'<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span><Leader><span class="pl-pds">"</span></span>, { remap <span class="pl-k">=</span> <span class="pl-c1">true</span> })</pre>
|
|
|
|
</div>
|
|
|
|
<p>Misc keymap:</p>
|
|
|
|
<div class="highlight highlight-source-lua">
|
|
|
|
<pre>vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>nzz<span class="pl-pds">"</span></span>)
|
|
|
|
vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>N<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>Nzz<span class="pl-pds">"</span></span>)
|
2023-07-04 06:24:03 +00:00
|
|
|
vim.<span class="pl-smi">keymap</span>.<span class="pl-c1">set</span>(<span class="pl-s"><span class="pl-pds">"</span>n<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>q<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>:q<CR><span class="pl-pds">"</span></span>)</pre>
|
2023-06-10 03:50:39 +00:00
|
|
|
</div>
|
|
|
|
<ul>
|
|
|
|
<li>
|
2023-07-04 06:24:03 +00:00
|
|
|
<p><code><Leader></code> prefix: prefer global keymap</p>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>
|
|
|
|
<code><Space></code> prefix: prefer lsp keymap, for coding of
|
|
|
|
course :D
|
|
|
|
</p>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>
|
|
|
|
With
|
|
|
|
<a href="https://github.com/ibhagwan/fzf-lua">ibhagwan/fzf-lua</a>:
|
|
|
|
</p>
|
|
|
|
<ul>
|
|
|
|
<li><code><Leader>f</code>: find files</li>
|
|
|
|
<li><code><Leader>rg</code>: grep files</li>
|
|
|
|
<li><code><Space>s</code>: find lsp symbols</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>
|
|
|
|
With
|
|
|
|
<a href="https://github.com/nvim-tree/nvim-tree.lua"
|
|
|
|
>nvim-tree/nvim-tree.lua</a
|
|
|
|
>, inside nvim-tree:
|
|
|
|
</p>
|
2023-06-23 07:40:04 +00:00
|
|
|
<ul>
|
2023-07-04 06:24:03 +00:00
|
|
|
<li><code><C-n></code>: toggle</li>
|
|
|
|
<li><code><Leader>n</code>: locate file</li>
|
2023-06-24 14:57:22 +00:00
|
|
|
<li><code>a</code>: create</li>
|
2023-06-23 07:40:04 +00:00
|
|
|
<li><code>d</code>: delete</li>
|
|
|
|
<li><code>r</code>: rename</li>
|
|
|
|
<li><code>x</code>: cut</li>
|
|
|
|
<li><code>c</code>: copy</li>
|
|
|
|
<li><code>p</code>: paste</li>
|
2023-06-24 15:24:39 +00:00
|
|
|
<li><code>U</code>: toggle hidden</li>
|
2023-06-23 07:40:04 +00:00
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li>
|
2023-07-04 06:24:03 +00:00
|
|
|
<p>
|
|
|
|
With
|
|
|
|
<a href="https://github.com/hrsh7th/nvim-cmp">hrsh7th/nvim-cmp</a>:
|
|
|
|
</p>
|
|
|
|
<ul>
|
|
|
|
<li><code><C-Space></code>: trigger completion</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<p>
|
|
|
|
With
|
|
|
|
<a href="https://github.com/lewis6991/gitsigns.nvim"
|
|
|
|
>lewis6991/gitsigns.nvim</a
|
|
|
|
>:
|
|
|
|
</p>
|
2023-06-10 03:50:39 +00:00
|
|
|
<ul>
|
2023-06-23 07:40:04 +00:00
|
|
|
<li><code>]c</code>, <code>[c</code>: next/previous git change</li>
|
2023-06-10 03:50:39 +00:00
|
|
|
</ul>
|
|
|
|
</li>
|
2023-07-08 11:31:12 +00:00
|
|
|
<li>
|
|
|
|
<p>
|
|
|
|
With
|
|
|
|
<a href="https://github.com/tpope/vim-projectionist"
|
|
|
|
>tpope/vim-projectionist</a
|
|
|
|
>
|
|
|
|
</p>
|
|
|
|
<ul>
|
|
|
|
<li><code>:A</code>: open alternate file</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
2023-06-10 03:50:39 +00:00
|
|
|
<li>
|
2023-07-04 06:24:03 +00:00
|
|
|
<p>
|
|
|
|
With
|
|
|
|
<a href="https://github.com/echasnovski/mini.nvim"
|
|
|
|
>echasnovski/mini.nvim</a
|
|
|
|
>
|
|
|
|
</p>
|
2023-06-10 03:50:39 +00:00
|
|
|
<ul>
|
|
|
|
<li>
|
2023-06-23 07:40:04 +00:00
|
|
|
With mini-bracketed
|
2023-06-10 03:50:39 +00:00
|
|
|
<ul>
|
2023-07-04 06:30:23 +00:00
|
|
|
<li>
|
2023-07-05 09:14:18 +00:00
|
|
|
<code>[B</code>, <code>]B</code>, <code>[b</code>,
|
|
|
|
<code>]b</code>: buffer backward/forward
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<code>[D</code>, <code>]D</code>, <code>[d</code>,
|
|
|
|
<code>]d</code>: diagnostic backward/forward
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<code>[Q</code>, <code>]Q</code>, <code>[q</code>,
|
|
|
|
<code>]q</code>: quickfix backward/forward
|
2023-07-04 06:30:23 +00:00
|
|
|
</li>
|
2023-06-10 03:50:39 +00:00
|
|
|
<li>
|
2023-06-23 07:40:04 +00:00
|
|
|
<code>[T</code>, <code>]T</code>, <code>[t</code>,
|
|
|
|
<code>]t</code>: tree-sitter backward/forward
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
Support more languages with
|
|
|
|
<a href="https://github.com/nvim-treesitter/nvim-treesitter"
|
|
|
|
>nvim-treesitter/nvim-treesitter</a
|
|
|
|
>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2023-06-10 03:50:39 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
2023-06-23 07:40:04 +00:00
|
|
|
<li>
|
|
|
|
With mini-comment
|
|
|
|
<ul>
|
|
|
|
<li><code>gcc</code>: comment/uncomment current line</li>
|
|
|
|
<li><code>gc</code>: comment/uncomment selected lines</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
With mini-surround
|
|
|
|
<ul>
|
|
|
|
<li><code>sa</code>: add surround</li>
|
|
|
|
<li><code>sd</code>: delete surround</li>
|
|
|
|
<li><code>sr</code>: replace surround</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
2023-07-04 06:24:03 +00:00
|
|
|
<li>
|
|
|
|
With mini-trailspace
|
|
|
|
<ul>
|
|
|
|
<li><code><Leader>tr</code>: trim trailing whitespace</li>
|
|
|
|
</ul>
|
|
|
|
</li>
|
2023-06-15 19:06:11 +00:00
|
|
|
</ul>
|
|
|
|
</li>
|
2023-06-29 10:29:18 +00:00
|
|
|
<li>
|
2023-07-04 06:24:03 +00:00
|
|
|
<p>
|
|
|
|
With
|
|
|
|
<a href="https://github.com/neovim/nvim-lspconfig"
|
|
|
|
>neovim/nvim-lspconfig</a
|
|
|
|
>
|
|
|
|
</p>
|
2023-06-29 10:29:18 +00:00
|
|
|
<ul>
|
2023-07-04 06:24:03 +00:00
|
|
|
<li><code><Space>gd</code>: go to definition</li>
|
|
|
|
<li><code><Space>k</code>: hover</li>
|
2023-06-29 10:29:18 +00:00
|
|
|
<li><code><F2></code>: rename</li>
|
2023-07-04 06:24:03 +00:00
|
|
|
<li><code><Space>ca</code>: code action</li>
|
|
|
|
<li><code><Space>gr</code>: go to references</li>
|
|
|
|
<li><code><Space>f</code>: format</li>
|
2023-06-29 10:29:18 +00:00
|
|
|
</ul>
|
|
|
|
</li>
|
2023-06-10 03:50:39 +00:00
|
|
|
</ul>
|
|
|
|
<h2>
|
|
|
|
<a
|
2023-07-07 09:58:37 +00:00
|
|
|
id="user-content-references--thanks"
|
2023-06-10 03:50:39 +00:00
|
|
|
class="anchor"
|
|
|
|
aria-hidden="true"
|
2023-07-07 09:58:37 +00:00
|
|
|
href="#references--thanks"
|
2023-06-10 03:50:39 +00:00
|
|
|
><span aria-hidden="true" class="octicon octicon-link"></span></a
|
2023-07-07 09:58:37 +00:00
|
|
|
>References / Thanks
|
2023-06-10 03:50:39 +00:00
|
|
|
</h2>
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
|
|
<a href="https://neovim.io/doc/user/motion.html" rel="nofollow"
|
|
|
|
>neovim Motion</a
|
|
|
|
>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<a href="http://neovim.io/doc/user/tagsrch.html" rel="nofollow"
|
|
|
|
>neovim Tagsrch</a
|
|
|
|
>
|
|
|
|
</li>
|
2023-07-01 09:06:30 +00:00
|
|
|
<li>
|
|
|
|
<a href="https://neovim.io/doc/user/lua-guide.html" rel="nofollow"
|
|
|
|
>neovim Lua-guide</a
|
|
|
|
>
|
|
|
|
</li>
|
2023-07-07 09:58:37 +00:00
|
|
|
<li>
|
|
|
|
<a
|
|
|
|
href="https://bluz71.github.io/2021/09/10/vim-tips-revisited.html"
|
|
|
|
rel="nofollow"
|
|
|
|
>Vim Tips (Revisited)</a
|
|
|
|
>
|
|
|
|
</li>
|
2023-06-10 03:50:39 +00:00
|
|
|
</ul>
|
2023-05-02 17:42:11 +00:00
|
|
|
|
|
|
|
<div>
|
|
|
|
Feel free to ask me via
|
|
|
|
<a href="mailto:hauvipapro+posts@gmail.com">email</a> or
|
|
|
|
<a rel="me" href="https://hachyderm.io/@haunguyen">Mastodon</a>. Source
|
|
|
|
code is available on
|
|
|
|
<a href="https://github.com/haunt98/posts-go">GitHub</a>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
|
|
</html>
|