From 4d53f559b1ad7699371d73d66e4ab8d6d232b13a Mon Sep 17 00:00:00 2001 From: Ryan Yin Date: Mon, 15 Jan 2024 14:35:17 +0800 Subject: [PATCH] docs: editors(vim) --- home/base/desktop/editors/README.md | 77 ++++++++++++++++++----------- 1 file changed, 49 insertions(+), 28 deletions(-) diff --git a/home/base/desktop/editors/README.md b/home/base/desktop/editors/README.md index 40c0d371..474afd2e 100644 --- a/home/base/desktop/editors/README.md +++ b/home/base/desktop/editors/README.md @@ -27,7 +27,7 @@ Type `:tutor`(`:Tutor` in Neovim) to learn the basics usage of vim/neovim. ## VIM's Cheetsheet -> Here only record my commonly used keys, to see **a more comprehensive cheetsheet**: +> Here only record my commonly used keys, to see **a more comprehensive cheetsheet**: Both Emacs-Evil & Neovim are compatible with vim, sothe key-bindings described here are common in both Emacs-Evil, Neovim & vim. @@ -44,7 +44,9 @@ I mainly use Zellij for terminal related operations, here is its terminal shortc ### File Management -> +> + +> | Action | | | --------------------------------- | ------------------------------------------------ | @@ -55,29 +57,48 @@ I mainly use Zellij for terminal related operations, here is its terminal shortc | Edit a file | `:e filename`(or `:e ` to show a file list) | | Browse the file list | `:Ex` or `:e .` | +### Motion + +> https://vimhelp.org/motion.txt.html + +| Action | Command | +| --------------------------------------------------- | ---------------------------------------- | +| Move to the start/end of the buffer | `gg`/`G` | +| Move the line number 5 | `5gg` / `5G` | +| Move left/down/up/right | h/j/k/l or `5h`/`5j`/`5k`/`5l` | +| Move to the matchpairs, default to `()`, `{}`, `[]` | `%` | +| Move to the start/end of the line | `0` / `$` | +| Move a sentence forward/backward | `(` / `)` | +| Move a paragraph forward/backward | `{` / `}` | +| Move a section forward/backward | `[[` / `]]` | +| Jump to various positions | `'` + some other keys(neovim has prompt) | + +Text Objects: + +- **sentence**: text ending at a '.', '!' or '?' followed by either the end of a line, or by a space or tab. +- **paragraph**: text ending at a blank line. +- **section**: text starting with a section header and ending at the start of the next section header (or at the end of the file). - The "`]]`" and "`[[`" commands stop at the '`{`' in the first column. This is + useful to find the start of a function in a C/Go/Java/... program. + ### Text Manipulation Basics: -| Action | | -| --------------------------------------------------- | ------------------------------ | -| Move to the start/end of the buffer | `gg`/`G` | -| Move the line number 5 | `5gg` / `5G` | -| Move left/down/up/right | h/j/k/l or `5h`/`5j`/`5k`/`5l` | -| Move to the matchpairs, default to `()`, `{}`, `[]` | `%` | -| Delete the current character | `x` | -| Paste the copied text | `p` | -| Delete the selection | `d` | -| Undo the last word | `CTRL-w`(in insert mode) | -| Undo the last line | `CTRL-u`(in insert mode) | -| Undo the last change | `u` | -| Redo the last change | `Ctrl + r` | -| Inserts the text of the previous insert | `Ctrl + a` | -| Repeat the last command | `.` | -| Toggle text's case | `~` | -| Convert to uppercase | `U` (visual mode) | -| Convert to lowercase | `u` (visual mode) | -| Align the selected conent | `:center`/`:left`/`:right` | +| Action | | +| --------------------------------------- | -------------------------- | +| Delete the current character | `x` | +| Paste the copied text | `p` | +| Delete the selection | `d` | +| Undo the last word | `CTRL-w`(in insert mode) | +| Undo the last line | `CTRL-u`(in insert mode) | +| Undo the last change | `u` | +| Redo the last change | `Ctrl + r` | +| Inserts the text of the previous insert | `Ctrl + a` | +| Repeat the last command | `.` | +| Toggle text's case | `~` | +| Convert to uppercase | `U` (visual mode) | +| Convert to lowercase | `u` (visual mode) | +| Align the selected conent | `:center`/`:left`/`:right` | Misc: @@ -97,7 +118,6 @@ Misc: | Sort tye selected lines | `:sort` | | Join Selection of Lines With Space | `:join` or `J` | | Join without spaces | `:join!` | -| Move to the start/end of the line | `0` / `$` | | Enter Insert mode at the start/end of the line | `I` / `A` | | Delete from the cursor to the end of the line | `D` | | Delete from the cursor to the end of the line, and then enter insert mode | `C` | @@ -159,7 +179,9 @@ The postfix(flags) in the above commands: ### Buffers, Windows and Tabs -> +> + +> - A buffer is the in-memory text of a file. - A window is a viewport on a buffer. @@ -177,8 +199,7 @@ The postfix(flags) in the above commands: ### History - -| Action | Command | -| ----------------------------------- | ----------------------------------- | -| Show the command history | `q:` | -| Show the search history | `q/` | +| Action | Command | +| ------------------------ | ------- | +| Show the command history | `q:` | +| Show the search history | `q/` |