1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-23 08:55:34 +02:00

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.
This commit is contained in:
Waldir Pimenta 2016-10-06 11:19:06 +01:00 committed by GitHub
parent 093bb6fea4
commit 4b7ef4a18d

View file

@ -1,31 +1,32 @@
# vim
> Vi IMproved, a programmer's text editor.
> 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 with cursor at the given line number:
- Open a file:
`vim {{file}} +{{linenumber}}`
`vim {{file}}`
- Open multiple files at once, each file in its own tab page:
`vim -p {{file1}} {{file2}} {{file3}}`
- Open a file in read-only mode:
`view {{file}}`
- Enter normal text editing mode (insert mode):
- Enter text editing mode (insert mode):
`<Esc> i`
- Search in file:
- Copy ("yank") or cut ("delete") the current line (paste it with `P`):
`/{{search_string}}<Enter>`
`<Esc> {{yy|dd}}`
- Save and Exit vim:
- 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>`
- Open interactive help:
`<Esc> :help <Enter>`