1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-30 01:35:29 +02:00
tldr/pages/common/vim.md
Waldir Pimenta 4b7ef4a18d vim: improve examples (#1105)
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.
2016-10-06 11:19:06 +01:00

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>`