mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-07-29 13:15:28 +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.
755 B
755 B
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>