26 lines
876 B
Markdown
26 lines
876 B
Markdown
---
|
|
title: vim
|
|
---
|
|
|
|
- Sort selected lines: `:sort`
|
|
- Open man page: `:man [command]` or `\K`
|
|
- Open URL: `gx`
|
|
- Move between splits: `ctrl+w [direction]`
|
|
- [vim-commentary](https://github.com/tpope/vim-commentary): `gc [motion]` to comment out
|
|
- Case switching:
|
|
- `gU` to uppercase
|
|
- `gu` to lowercase -`g~` to toggle
|
|
- Substitute:
|
|
- `/g` **global** - sub all in line
|
|
- `:%s/` - substitute in all lines
|
|
- `:5,12s/` substitute from lines 5 to 12
|
|
- `:.,+2s/` substitute this line (`.`) and the next 2
|
|
- `:g/^foo/s/bar/baz/g` substitute all instances of bar with baz on lines beginning with foo
|
|
- `/c` - ask for confirmation
|
|
- Windows
|
|
- `:sp [filename]` horizontal split, optionally open file
|
|
- `vsp` vertical split
|
|
- `ctrl+w w` move between windows
|
|
- `ctrl+w =` resize windows to be equal
|
|
- `ctrl+w q` close window
|
|
- `ctrl+w <direction>` move window
|