tldr/pages/common/vim.md

38 lines
756 B
Markdown
Raw Normal View History

2015-12-28 12:06:58 +00:00
# vim
> Vim (Vi IMproved), a command-line text editor, provides several modes for different kinds of text manipulation.
> Pressing `i` enters edit mode. `<Esc>` goes back to normal mode, which doesn't allow regular text insertion.
> More information: <https://www.vim.org>.
2015-12-28 12:06:58 +00:00
- Open a file:
2015-12-28 12:06:58 +00:00
2020-01-22 23:38:21 +00:00
`vim {{path/to/file}}`
2015-12-28 12:06:58 +00:00
- View Vim's help manual:
`:help<Enter>`
2020-01-22 23:38:21 +00:00
- Save a file:
2015-12-28 12:06:58 +00:00
`:write<Enter>`
2015-12-28 12:06:58 +00:00
2020-01-22 23:38:21 +00:00
- Quit without saving:
`:quit!<Enter>`
2020-01-22 23:38:21 +00:00
- Open a file at a specified line number:
`vim +{{line_number}} {{path/to/file}}`
- Undo the last operation:
2015-12-28 12:06:58 +00:00
`u`
2015-12-29 17:09:30 +00:00
- Search for a pattern in the file (press `n`/`N` to go to next/previous match):
2015-12-29 17:09:30 +00:00
`/{{search_pattern}}<Enter>`
2015-12-29 17:09:30 +00:00
2017-10-21 21:01:49 +01:00
- Perform a regex substitution in the whole file:
2016-01-05 22:07:51 +00:00
`:%s/{{pattern}}/{{replacement}}/g<Enter>`