-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvi-keys+
More file actions
151 lines (132 loc) · 5.27 KB
/
vi-keys+
File metadata and controls
151 lines (132 loc) · 5.27 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# Keys from emacs mode. Anything that doesn't conflict gets to stay.
bindkey -v # start with vi keys
autoload edit-command-line; zle -N edit-command-line
bindkey -M vicmd v edit-command-line
# The classics of emacs bindings:
bindkey "^A" beginning-of-line
bindkey "^B" backward-char
bindkey "^D" delete-char-or-list
bindkey "^E" end-of-line
bindkey "^F" forward-char
bindkey "^G" send-break
bindkey "^H" backward-delete-char
bindkey "^I" expand-or-complete
bindkey "^K" kill-line
bindkey "^N" down-line-or-history
bindkey "^P" up-line-or-history
bindkey "^R" history-incremental-search-backward
bindkey "^S" history-incremental-search-forward
bindkey "^T" transpose-chars
bindkey "^U" kill-whole-line
bindkey "^Y" yank
bindkey "^[b" backward-word
bindkey "^[f" forward-word
bindkey "^[d" kill-word
# And now, for some exciting ones, if you've only used vi keys…
bindkey "^[." insert-last-word # Alt+'.' gives !$'s value.
bindkey "^[?" which-command # Shows "which" output for the current command
bindkey "^[H" run-help # run "man" on current command (Alt+Shift+h)
bindkey -M vicmd "^[H" run-help
# Say you ran:
# % cd ~/src/foo
# % vim lib/foo.rb
# % rake test
#
# You could ^r to find the "cd ~/src/foo" line, then hit ^o twice to
# execute the subsequent commands.
bindkey "^O" accept-line-and-down-history
# Cut the contents of the line then paste when the next prompt appears.
# (kind of like backgrounding the current command line for 1 command)
bindkey "^Q" push-line
bindkey "^[Q" push-line
bindkey "^[q" push-line
bindkey -M vicmd "^[q" push-line
bindkey "^['" quote-line # Very useful. E.g. to echo a command into a file.
bindkey -M vicmd "^['" quote-line
# Searches history for the current command, then puts the line *after that*
# into the edit buffer. Funky but interesting.
bindkey "^X^N" infer-next-history
# Kinda like vim's ^O — one-shot vi cmd
bindkey "^X^V" vi-cmd-mode
# Run through line (or arg, depending on context) history
bindkey "^[N" history-search-forward
bindkey "^[n" history-search-forward
bindkey "^[P" history-search-backward
bindkey "^[p" history-search-backward
# duplicate the token to the left:
bindkey "^[^_" copy-prev-word
bindkey "^[ " expand-history
# Things that have more efficient bindings, but keeping for compatibility with
# people used to them:
bindkey "^X^B" vi-match-bracket # vi: %
bindkey "^X^F" vi-find-next-char # vi: f
bindkey "^X^J" vi-join # vi: J
bindkey "^X^K" kill-buffer # ^u^k
bindkey "^X^O" overwrite-mode # vi: R
bindkey "^X^U" undo # vi: u
bindkey "^Xu" undo
bindkey "^X=" what-cursor-position # Show char info, like vim ga + g^g
bindkey "^Xr" history-incremental-search-backward # Same as ^r
bindkey "^Xs" history-incremental-search-forward # Same as ^s # For stty ixon?
bindkey "^[^H" backward-kill-word # Same as ^w.
bindkey "^[^L" clear-screen # ^L
bindkey "^[^G" send-break # ^G
bindkey "^[<" beginning-of-buffer-or-history # gg
bindkey "^[>" end-of-buffer-or-history # G
bindkey "^[OA" up-line-or-history # ^p or vi: k
bindkey "^[[A" up-line-or-history # (same)
bindkey "^[OB" down-line-or-history # ^n or vi: j
bindkey "^[[B" down-line-or-history # (same)
bindkey "^[[C" forward-char # ^f or vi: l
bindkey "^[[D" backward-char # ^b or vi: h
bindkey "^[_" insert-last-word # Alt+.
bindkey "^_" undo
bindkey "^?" backward-delete-char
# Fined grained expansion vs. completion. (Tab is generally handier)
bindkey "^X*" expand-word # "Shell expansion of current word"
bindkey "^[!" expand-history # "History expansion on the edit buffer"
bindkey "^[^D" list-choices # Show, but don't complete, possible completions
bindkey "^Xg" list-expand # Show, but don't expand, expansion. (c.f., ^d)
bindkey "^XG" list-expand
# TODO: Learn about emacs-like marks handling and enable these:
#bindkey "^@" set-mark-command
#bindkey "^X^X" exchange-point-and-mark
#bindkey "^[\"" quote-region
#bindkey "^[G" get-line # "Pop the top line off the buffer stack and
#bindkey "^[w" copy-region-as-kill
#bindkey "^[y" yank-pop
# TODO: Learn these, too:
#bindkey "^[\$" spell-word
#bindkey "^[-" neg-argument # TODO: figure out how to use this
# And now, for the bummer of the story.
# Since that ^[x means Alt+x, zsh can't distinguish between the two. Maybe
# there's a way to get them to work without robbing the vi-key siblings.
#
# I tried KEYTIMEOUT and that was fail. (It nixes the ability to bind "^X;"
# (from zaw) and "di(" (from ./vim-keys)
#bindkey "^[a" accept-and-hold
#bindkey "^[c" capitalize-word
#bindkey "^[g" get-line
#bindkey "^[D" kill-word
#bindkey "^[h" run-help
#bindkey "^[A" accept-and-hold
#bindkey "^[C" capitalize-word
#bindkey "^[L" down-case-word
#bindkey "^[S" spell-word
#bindkey "^[T" transpose-words
#bindkey "^[U" up-case-word
#bindkey "^[l" down-case-word
#bindkey "^[s" spell-word
#bindkey "^[t" transpose-words
#bindkey "^[u" up-case-word
#bindkey "^[W" copy-region-as-kill
#bindkey "^[x" execute-named-cmd
#bindkey "^[z" execute-last-named-cmd
#bindkey "^[|" vi-goto-column
#bindkey "^[^?" backward-kill-word
#-----------------------------------------
# Docs for these widgets are kind of here:
# http://zsh.sourceforge.net/Doc/Release/Zsh-Line-Editor.html
# Some details are here:
# https://github.com/zsh-users/zsh/tree/master/Functions/Zle
# vim:ft=zsh