193 vi-cmd-mode() { |
193 vi-cmd-mode() { |
194 show_mode "$__string_normal" |
194 show_mode "$__string_normal" |
195 builtin zle .vi-cmd-mode |
195 builtin zle .vi-cmd-mode |
196 } |
196 } |
197 zle -N vi-cmd-mode |
197 zle -N vi-cmd-mode |
198 bindkey -M viins "" vi-cmd-mode |
198 bindkey -M viins "^[" vi-cmd-mode |
199 |
199 |
200 |
200 |
201 ### vi-oper-swap-case |
201 ### vi-oper-swap-case |
202 ### Read a movement command from the keyboard, and swap |
202 ### Read a movement command from the keyboard, and swap |
203 ### the case of all characters from the cursor position |
203 ### the case of all characters from the cursor position |
204 ### to the endpoint of the movement. If the movement |
204 ### to the endpoint of the movement. If the movement |
205 ### command is vi-oper-swap-case, swap the case of all |
205 ### command is vi-oper-swap-case, swap the case of all |
206 ### characters on the current line. |
206 ### characters on the current line. |
207 ### |
207 ### |
208 |
208 |
209 bindkey -M vicmd "g~" vi-oper-swap-case |
209 # Specific to command mode |
|
210 bindkey -M vicmd "g~" vi-oper-swap-case |
210 bindkey -M vicmd 'guw' down-case-word |
211 bindkey -M vicmd 'guw' down-case-word |
211 bindkey -M vicmd 'gUw' up-case-word |
212 bindkey -M vicmd 'gUw' up-case-word |
212 |
213 |
213 |
214 bindkey -M vicmd "^[[2~" vi-insert |
214 bindkey -M vicmd "[2~" vi-insert |
|
215 bindkey -M vicmd 'q' push-line |
215 bindkey -M vicmd 'q' push-line |
216 bindkey -M vicmd '[5~' history-beginning-search-backward # PgUp |
216 |
217 bindkey -M vicmd '[6~' history-beginning-search-forward # PgDn |
217 # Specific to insert mode |
218 |
|
219 bindkey -M viins '[5~' history-beginning-search-backward # PgUp |
|
220 bindkey -M viins '[6~' history-beginning-search-forward # PgDn |
|
221 bindkey -M viins '[7~' beginning-of-line |
|
222 bindkey -M viins '[8~' end-of-line |
|
223 bindkey -M viins '^A' beginning-of-line |
218 bindkey -M viins '^A' beginning-of-line |
224 bindkey -M viins '^E' end-of-line |
219 bindkey -M viins '^E' end-of-line |
225 bindkey -M viins '[3~' delete-char |
220 |
226 bindkey -M viins '[A' up-line-or-history |
221 bindkey -M viins '^[[5~' history-beginning-search-backward # PgUp |
227 bindkey -M viins '[B' down-line-or-history |
222 bindkey -M viins '^[[6~' history-beginning-search-forward # PgDn |
|
223 |
|
224 bindkey -M viins '^[[A' up-line-or-history |
|
225 bindkey -M viins '^[[B' down-line-or-history |
|
226 |
228 bindkey -M viins '^Xc' copy-prev-shell-word |
227 bindkey -M viins '^Xc' copy-prev-shell-word |
229 bindkey -M viins '^Xf' _correct_filename |
228 bindkey -M viins '^Xf' _correct_filename |
230 bindkey -M viins '^_' undo |
229 bindkey -M viins '^_' undo |
231 bindkey -M viins '^K' vi-change-eol |
230 bindkey -M viins '^K' vi-change-eol |
232 bindkey -M viins '^R' history-incremental-search-backward |
231 bindkey -M viins '^R' history-incremental-search-backward |
234 bindkey -M viins '^T' transpose-chars |
233 bindkey -M viins '^T' transpose-chars |
235 bindkey -M viins '^Xm' _most_recent_file |
234 bindkey -M viins '^Xm' _most_recent_file |
236 bindkey -M viins '^P' _history-complete-older |
235 bindkey -M viins '^P' _history-complete-older |
237 bindkey -M viins '^N' _history-complete-newer |
236 bindkey -M viins '^N' _history-complete-newer |
238 |
237 |
|
238 # Both modes |
|
239 bindkey -M viins '^[[7~' beginning-of-line |
|
240 bindkey -M vicmd '^[[7~' beginning-of-line |
|
241 bindkey -M viins '^[[8~' end-of-line |
|
242 bindkey -M vicmd '^[[8~' end-of-line |
|
243 |
|
244 bindkey -M viins '^[[H' beginning-of-line |
|
245 bindkey -M vicmd '^[[H' beginning-of-line |
|
246 bindkey -M viins '^[[F' end-of-line |
|
247 bindkey -M vicmd '^[[F' end-of-line |
|
248 |
|
249 bindkey -M viins '^[[3~' delete-char |
|
250 bindkey -M vicmd '^[[3~' delete-char |
|
251 |
239 bindkey -M viins -s '^X^H' 'hash -r\n' |
252 bindkey -M viins -s '^X^H' 'hash -r\n' |
240 |
253 |
241 # These bindings depend on the ftzle script |
254 # These bindings depend on the ftzle script |
242 bindkey -M viins "^X^W" backward-kill-to-slash |
255 bindkey -M viins "^X^W" backward-kill-to-slash |
243 bindkey '^I' ft-complete |
256 bindkey '^I' ft-complete |
244 |
257 |
245 |
258 |
246 if [[ -z ${TERM:#screen} ]]; then |
259 if [[ -z ${TERM:#screen} ]]; then |
247 bindkey -M viins '[1~' beginning-of-line # Home |
260 bindkey -M viins '^[[1~' beginning-of-line # Home |
248 bindkey -M viins '[4~' end-of-line # End |
261 bindkey -M vicmd '^[[1~' beginning-of-line # Home |
|
262 bindkey -M viins '^[[4~' end-of-line # End |
|
263 bindkey -M vicmd '^[[4~' end-of-line # End |
249 fi |
264 fi |
250 |
265 |
251 # Edit the command line using your usual editor. |
266 # Edit the command line using your usual editor. |
252 autoload edit-command-line |
267 autoload edit-command-line |
253 zle -N edit-command-line |
268 zle -N edit-command-line |