forked from mawww/kakoune
-
Notifications
You must be signed in to change notification settings - Fork 0
/
VIMTOKAK
67 lines (51 loc) · 2.22 KB
/
VIMTOKAK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
Vi(m) to Kakoune:
=================
Kakoune is inspired heavily by Vim. It strives to be as efficient as Vim,
more consistent and simpler. A big difference is that a lot of special
features in Vim just become regular interactions of basic features in
Kakoune.
Operations and moves are reversed in Kakoune. First select whatever text
you want to operate on, and then use a modifying operation. That makes
things more consistent: Vim needs separate x and d operations because
of the operator -> move order, while Kakoune only needs the d operation.
Selecting first also allows more complex selections.
delete a word:
* vim: dw
* kak: wd
delete a character:
* vim: x
* kak: d or ;d (; reduces the selection to a single char)
copy a line:
* vim: yy
* kak: xy
global replace:
* vim: :%s/word/replacement<ret>
* kak: %sword<ret>creplacement<esc>
Explanation: '%' selects the entire buffer, 's' opens a prompt for a
regex, <ret> validates the regex and replaces the selection with one
per match (hence all occurences of "word" are selected). 'c' deletes
the selection contents and enters insert mode where "replacement" is typed,
and <esc> goes back to normal mode.
Note that the Kakoune version is one key less, and is not a special
feature per se, but just a nice way Kakoune features work together.
replace in current curly brace block:
* vim: viB:s/word/replacement<ret>
* kak: <a-i>Bsword<ret>creplacement<esc>
Here again, Vim had to rely on a special feature, visual mode.
join line with next:
* vim: J
* kak: <a-J>
delete to line end:
* vim: d$
* kak: <a-l>d or Gld
Some classic Vim moves are not bound to the same key. Kakoune
uses shifted moves to extend the selection, so Vim moves that were bound to
shifted characters had to change.
* % became m (for "matching"). However, m replaces the selection with the next
block. If you want to get a selection from the current point to the next
block's end, you should use ;M (; reduces the selection to one character).
* 0 and $ became <a-h> and <a-l>. Equivalent bindings are gh and gl.
:[gv]/re/cmd
To emulate :g or :v, use % to select the whole buffer, <a-s> to get
one selection per line, and then <a-k> or <a-K> to keep only the
selections matching (or not matching) the entered regex.