From 19bc10c03a2f2de8e7f0968a4a59f9289c6be854 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sat, 27 Jul 2019 17:32:02 -0700 Subject: Add some fresh vim tips --- vim.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/vim.md b/vim.md index c69b9c4..f652188 100644 --- a/vim.md +++ b/vim.md @@ -13,6 +13,42 @@ | `'` | `:h 'ro'` | option | | `-` | `:h -r` | Vim argument (starting Vim) | +## Registers + +: is the "last command" register. @: reruns the last command. + +## Marks + +mA - capital letters are global, will jump to file +`a - jumps to line and column of mark, not just line + +## v/V/ as operators + +Most commands act line-wise (d2j deletes two lines). v makes things +character-wise, makes them block-wise. + +## Ranges + + g/regex/command # executes command on each line matching regex + v/regex/command # executes command on each line not matching regex + +## Ex commands + + :norm abc # runs the keys abc on each line in range + :g/abc/norm dt; # deletes until semicolon on each line with "abc" + + :co # copies range to location (can be ., +n, 'a) + :mv # same but moves + +## Visual mode + +gv - selects the previous visual +g - increment/decrement by 1 more on each selected line + + 0 1 1 + 0 -> 1 g -> 2 + 0 1 3 + ## Using vim as a hex editor? :%!xxd -- cgit v1.2.3