From 60608a8b1e91dfcc0b93b20df46b207448e43ed7 Mon Sep 17 00:00:00 2001 From: Ariejan de Vroom Date: Mon, 3 Apr 2017 11:04:56 +0200 Subject: [PATCH] Initial version of my vim cheatsheet --- content/vim-cheatsheet.md | 88 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 content/vim-cheatsheet.md diff --git a/content/vim-cheatsheet.md b/content/vim-cheatsheet.md new file mode 100644 index 0000000..7c7da4b --- /dev/null +++ b/content/vim-cheatsheet.md @@ -0,0 +1,88 @@ ++++ +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 ,. + +## Comments + +Provided by `tomtom/tcomment_vim`, it allows to easily comment/uncomments code. + + * gcc Toggles comment for the current line + +In Visual mode + + * gc 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"` + + * cs"' → `'Hello World'` + * cs'<q> → `Hello World` + * cst" → `"Hello World"` + * ds" → `Hello World` + * ysiw<em> on Hello → `Hello World` + * Visually select line, S<p class="important"> → + +```text +

+Hello Worls +

+``` + +## 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 ,a=: + +```text +a = 1 +b = 42 +test = 512 +``` + +Similarly, using ,a: + +```text +a: 1, +b: 42, +test: 512 +``` + +results in: + +```text +a: 1, +b: 42, +test: 512 +``` +