红穆笔记

nvim

Neovim,基於 Vim 的代碼編輯器,使用多種不同的模式來修改文本。 在普通模式(normal mode)下,按下 `` 鍵以進入插入模式(insert mode)。通過 `<Esc>` 或 `<Ctrl c>` 返回普通模式。普通模式下不支持一般的文本輸入。 另請參閱:`vim`, `vimtutor`, `vimdiff`。 <https://neovim.io/>

100% 瀏覽器本地處理 0 數據上傳

常用示例

打開文件

nvim {{path/to/file}}

進入文本編輯模式(insert mode)

<Esc><i>

複製("yank")或剪切("delete")當前行(使用 `<p>` 粘貼)

<Esc>{{<y><y>|<d><d>}}

進入普通模式並撤消上次操作

<Esc><u>

在當前文件中使用正則表達式搜索(使用 `<n>`/`<N>` 查看上一個/下一個搜索結果)

<Esc></>{{search_pattern}}<Enter>

在當前文件中使用`regex`式進行全局替換

<Esc><:>%s/{{regular_expression}}/{{replacement}}/g<Enter>

進入普通模式,保存文件並退出

{{<Esc><Z><Z>|<Esc><:>x<Enter>|<Esc><:>wq<Enter>}}

退出並不保存更改

<Esc><:>q!<Enter>

提示:花括號{{…}}是需要替換的參數(路徑、文件名等);命令只在本機終端執行,本站不保存任何輸入。

英文原文對照

展開英文說明與示例(來源 tldr-pages)

Neovim, a programmer's text editor based on Vim, provides several modes for different kinds of text manipulation. Pressing `` in normal mode enters insert mode. `<Esc>` or `<Ctrl c>` goes back to normal mode, which doesn't allow regular text insertion. See also: `vim`, `vimtutor`, `vimdiff`. More information: <https://neovim.io/>

Open a file

nvim {{path/to/file}}

Enter text editing mode (insert mode)

<Esc><i>

Copy ("yank") or cut ("delete") the current line (paste it with `<p>`)

<Esc>{{<y><y>|<d><d>}}

Enter normal mode and undo the last operation

<Esc><u>

Search for a pattern in the file (press `<n>`/`<N>` to go to next/previous match)

<Esc></>{{search_pattern}}<Enter>

Perform a `regex` substitution in the whole file

<Esc><:>%s/{{regex}}/{{replacement}}/g<Enter>

Enter normal mode and save (write) the file, and quit

{{<Esc><Z><Z>|<Esc><:>x<Enter>|<Esc><:>wq<Enter>}}

Quit without saving

<Esc><:>q!<Enter>

命令信息

命令名nvim
用途Neovim,基於 Vim 的代碼編輯器,使用多種不同的模式來修改文本。 在普通模式(normal mode)下,按下 `` 鍵以進入插入模式(insert mode)。通過 `<Esc>` 或 `<Ctrl c>` 返回普通模式。普通模式下不支持一般的文本輸入。 另請參閱:`vim`, `vimtutor`, `vimdiff`。 <https://neovim.io/>
適用平臺通用
示例數量8 條
官方文檔i
數據來源tldr-pages(CC-BY-4.0)· 社區中文翻譯

常見問題

nvim 命令是做什麼的?

Neovim,基於 Vim 的代碼編輯器,使用多種不同的模式來修改文本。 在普通模式(normal mode)下,按下 `` 鍵以進入插入模式(insert mode)。通過 `<Esc>` 或 `<Ctrl c>` 返回普通模式。普通模式下不支持一般的文本輸入。 另請參閱:`vim`, `vimtutor`, `vimdiff`。 <https://neovim.io/>

nvim 怎麼用?

頁面按場景列出了8 條常用示例:每條示例先說明用途,再給出可直接複製的完整命令(花括號裏是需要替換的參數)。

nvim 最常用的操作是什麼?

打開文件:nvim {{path/to/file}}

命令裏的花括號是什麼意思?

花括號{{…}}表示需要替換成你自己的值,例如路徑、文件名;同名參數方括號(如 [-C|--directory])表示可選寫法。