articles/vi.md: update

This commit is contained in:
tocariimaa 2025-03-09 18:28:41 -03:00
parent 1b8caab62e
commit 189935d6e5

View file

@ -30,7 +30,7 @@ in doubt of something by using the `:help <topic>` command or `<F1>` to access t
Some of these can be prefixed with a register name and a count number (in that order). Some of these can be prefixed with a register name and a count number (in that order).
Commands that work with registers use by default an anonymous registers if none is explicitly specified. Commands that work with registers use by default an anonymous registers if none is explicitly specified.
`c`: command mode, `i` = insert mode; `v`: visual mode; `n`: normal mode. `c`: command mode, `i` = insert mode; `v`: visual mode; `n`: normal mode; `t`: terminal mode.
### Basics ### Basics
- `:e`: open file in a new buffer, file needn't exist - `:e`: open file in a new buffer, file needn't exist
@ -113,9 +113,15 @@ It has to be noted that `Home`, `End`, `PageUp/Down` and cursor keys also work.
- `fe`: move to `e` - `fe`: move to `e`
- (n) `F`: move to specified character, backwards - (n) `F`: move to specified character, backwards
### Searching ### Search & Replace
- (n) `/`: search for pattern, forwards - (n) `/`: search for pattern, forwards
- (n) `?`: search for pattern, backwards - (n) `?`: search for pattern, backwards
- (n) `s`: replace (substitute) matches
The `%` expands to the current file name of the current buffer. It is required if you want
to apply `s` to the entire file, because it defaults to the current line only (therefore the `g` flag actually is global
to the current line and not the file). This by the way, is legacy from earlier line-based **ed**itors.
- `%s/pattertosearch/replacement/g`: replace all instances of `pattertosearch` by `replacement` in the file
- `%s/foo/bar/gc`: prompt for each possible replacement
### Other ### Other
- (n) `~`: change case of current character under the cursor - (n) `~`: change case of current character under the cursor
@ -126,9 +132,13 @@ It has to be noted that `Home`, `End`, `PageUp/Down` and cursor keys also work.
- (n) `K`: look for the identifier under the cursor in the man pages, really useful when you're doing C programming. - (n) `K`: look for the identifier under the cursor in the man pages, really useful when you're doing C programming.
- (n) `.`: repeat last action - (n) `.`: repeat last action
- `:help`, `:h`: Vim help pages - `:help`, `:h`: Vim help pages
- `:!`: execute shell command (in the shell specified by the `shell` varible) - `:!`: execute shell command (in the shell specified by the `shell` variable)
- `:r!`: execute shell command and paste the stdout of that command in the current buffer at where the cursor is - `:r!`: execute shell command and paste the stdout of that command in the current buffer at where the cursor is
- `:w !`: (not `:w!`) send buffer or current range to the specified shell command - `:w !`: (not `:w!`) send buffer or current range to the specified shell command
- `:term`: opens a terminal window, enters to a special `terminal` mode, similar to insert mode.
- (t) `Ctrl-\ Ctrl-n`: escape from terminal (Escape gets sent literally to the terminal process), also you may want to remap this
- `:mkses`: saves current session (optionally takes a filename where to save the session; `Session.vim` by default)
- `:so`: Source VimScript file, also used to restore from a session file.
### Macros ### Macros
- (n) `q`: start recording macro to register - (n) `q`: start recording macro to register
@ -183,7 +193,8 @@ It has to be noted that `Home`, `End`, `PageUp/Down` and cursor keys also work.
## vi-like editors ## vi-like editors
- Vim: vi improved, one of the most popular vi-like editors; includes a scripting language, - Vim: vi improved, one of the most popular vi-like editors; includes a scripting language,
VimScript for extending the editor. VimScript for extending the editor.
- Neovim: a fork of Vim, adds [Lua](lua.md) as a replacement for VimScript, improves performance. - Neovim: a fork of Vim, adds [Lua](lua.md) as a replacement for VimScript, improves performance, cleans cruft from
Vim's codebase (has less LOC than Vim).
- nvi: reimplementation of the original Berkley vi, is the default `vi` editor in the [BSDs](bsd.md). - nvi: reimplementation of the original Berkley vi, is the default `vi` editor in the [BSDs](bsd.md).
- vis: minimalistic vi-like editor, adds structured regular expressions inspired by the [Sam](sam.md) and - vis: minimalistic vi-like editor, adds structured regular expressions inspired by the [Sam](sam.md) and
[Acme](acme.md) editors, includes Lua for scripting. [Acme](acme.md) editors, includes Lua for scripting.