mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-07-30 01:35:29 +02:00

I tried to condense the most useful basic commands into this page without surpassing our length limit. I also expanded the main description -- I wonder if there's a way to phrase it which could allow us to get rid of all the <Esc>s... I combined copy/cut/paste into a single command, since it was important to allow space for a slightly more advanced command, (the find/replace example), which introduces some important vim concepts, such as command application ranges.
32 lines
755 B
Markdown
32 lines
755 B
Markdown
# vim
|
|
|
|
> Vi IMproved, a programmer's text editor, providing several modes for different kinds of text manipulation.
|
|
> Pressing `i` enters edit mode; the normal mode (accessed via `<Esc>`) doesn't allow regular text editing.
|
|
|
|
- Open a file:
|
|
|
|
`vim {{file}}`
|
|
|
|
- Enter text editing mode (insert mode):
|
|
|
|
`<Esc> i`
|
|
|
|
- Copy ("yank") or cut ("delete") the current line (paste it with `P`):
|
|
|
|
`<Esc> {{yy|dd}}`
|
|
|
|
- Undo the last operation:
|
|
|
|
`<Esc> u`
|
|
|
|
- Search for a pattern in the file (press `n` to go to the next result):
|
|
|
|
`<Esc> /{{search_pattern}} <Enter>`
|
|
|
|
- Perform a regex substitution in the whole file (from the start, `1`, to the end, `$`):
|
|
|
|
`<Esc> :1,$s/{{pattern}}/{{replacement}}/g <Enter>`
|
|
|
|
- Save (write) the file, and quit vim:
|
|
|
|
`<Esc> :wq <Enter>`
|