89 lines
1.7 KiB
Markdown
89 lines
1.7 KiB
Markdown
+++
|
|
type = "page"
|
|
title = "Vim Cheatsheet"
|
|
+++
|
|
|
|
This _Vim Cheatsheet_ is compatible with my [`~/.vimrc`](https://git.devroom.io/ariejan/dotfiles/blob/master/vim/.vimrc)
|
|
|
|
_This is an ongoing effort to document motions and commands available from my `~/.vimrc`_
|
|
|
|
## Leader
|
|
|
|
Leader is mapped to <kbd>,</kbd>.
|
|
|
|
## Comments
|
|
|
|
Provided by `tomtom/tcomment_vim`, it allows to easily comment/uncomments code.
|
|
|
|
* <kbd>gcc</kbd> Toggles comment for the current line
|
|
|
|
In Visual mode
|
|
|
|
* <kbd>gc</kbd> Toggle comments for the current selection
|
|
|
|
## Surroundings (parentheses, brackets, quotes and more)
|
|
|
|
`tpope/vim-surround` takes care of dealing with parentheses, brackets, quotes, XML tages
|
|
and more.
|
|
|
|
`"Hello World"`
|
|
|
|
* <kbd>cs"'</kbd> → `'Hello World'`
|
|
* <kbd>cs'<q></kbd> → `<q>Hello World</q>`
|
|
* <kbd>cst"</kbd> → `"Hello World"`
|
|
* <kbd>ds"</kbd> → `Hello World`
|
|
* <kbd>ysiw<em></kbd> on Hello → `<em>Hello</em> World`
|
|
* Visually select line, <kbd>S<p class="important"></kbd> →
|
|
|
|
```text
|
|
<p class="important">
|
|
<em>Hello</em> Worls
|
|
</p>
|
|
```
|
|
|
|
## Tabularize
|
|
|
|
Make lists of assignments and such more readable. This feature is _auto enabled_ while typing
|
|
for Cucumber/Gherkin style example (using `|`).
|
|
|
|
```cucumber
|
|
Background:
|
|
Given I have the following recipes:
|
|
| name | rating |
|
|
| Spaghetti | 4 |
|
|
| Lasgna Bolognese | 5 |
|
|
```
|
|
|
|
You can also manually invoke Tabularize:
|
|
|
|
```text
|
|
a = 1
|
|
b = 42
|
|
test = 512
|
|
```
|
|
|
|
Visually select, then <kbd>,a=</kbd>:
|
|
|
|
```text
|
|
a = 1
|
|
b = 42
|
|
test = 512
|
|
```
|
|
|
|
Similarly, using <kbd>,a:</kbd>
|
|
|
|
```text
|
|
a: 1,
|
|
b: 42,
|
|
test: 512
|
|
```
|
|
|
|
results in:
|
|
|
|
```text
|
|
a: 1,
|
|
b: 42,
|
|
test: 512
|
|
```
|
|
|