Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

254 lines (214 sloc) 6.209 kb
### KEY BINDINGS
# vi keybindings
bindkey -v
zle -C all-matches complete-word _generic
zle -C match-word complete-word _generic
bindkey '^Xx' all-matches
bindkey '\e*' match-word
bindkey "^Xq" push-line
bindkey "^Xr" history-incremental-search-backward
bindkey "^Xs" history-incremental-search-forward
bindkey "^X_" insert-last-word
bindkey "^Xa" accept-and-hold
bindkey "^X^H" run-help
bindkey "^Xh" _complete_help
bindkey "^I" expand-or-complete
bindkey "^E" expand-word
bindkey "^N" menu-complete
bindkey "^P" reverse-menu-complete
bindkey -M vicmd "^R" redo
bindkey -M vicmd "u" undo
bindkey -M vicmd "ga" what-cursor-position
### VI MODE EXTENSIONS
redisplay() {
builtin zle .redisplay
# L=$[LINES - 1]
# echo -n "\033[$L;0;H"
( true ; show_mode "INSERT") &!
}
redisplay2() {
builtin zle .redisplay
# L=$[LINES - 1]
# echo -n "\033[$L;0;H"
(true ; show_mode "NORMAL") &!
}
zle -N redisplay
zle -N redisplay2
bindkey -M viins "^X^R" redisplay
bindkey -M vicmd "^X^R" redisplay2
screenclear () {
echo -n "\033[2J\033[400H"
#repeat $[LINES - 2] echo
builtin zle .redisplay
# builtin zle .clear-screen
(true ; show_mode "INSERT") &!
}
zle -N screenclear
bindkey " " screenclear
screenclearx () {
# print -n '7'
repeat 2 print
local MYLINE="$LBUFFER$RBUFFER"
highlight $MYLINE
repeat 4 print
builtin zle redisplay
# print -n '8'
# print "${COLORX}Hit Enter to continue${COLOROFF}"
# read -k
}
zle -N screenclearx
bindkey "^Xl" screenclearx
#bindkey "^L" screenclearx
show_mode() {
local COL
local x
COL=$[COLUMNS-3]
COL=$[COL-$#1]
#x=$(wc -l $PREBUFFER)
x=$(echo $PREBUFFER | wc -l )
x=$[x+1]
# echo -n "7[0;$COL;H"
echo -n "7[$x;A"
echo -n ""
# c='`'
# echo -n "7[0$c"
echo -n "--$1--"
echo -n "8"
}
### vi-add-eol (unbound) (A) (unbound)
### Move to the end of the line and enter insert mode.
vi-add-eol() {
show_mode "INSERT"
builtin zle .vi-add-eol
}
zle -N vi-add-eol
bindkey -M vicmd "A" vi-add-eol
### vi-add-next (unbound) (a) (unbound)
### Enter insert mode after the current cursor posi­
### tion, without changing lines.
vi-add-next() {
show_mode "INSERT"
builtin zle .vi-add-next
# OLDLBUFFER=$LBUFFER
# OLDRBUFFER=$RBUFFER
# NNUMERIC=$NUMERIC
# bindkey -M viins "" vi-cmd-mode-a
}
zle -N vi-add-next
bindkey -M vicmd "a" vi-add-next
#vi-cmd-mode-a() {
# show_mode "NORMAL"
# STRING="LLBUFFER=\${LBUFFER:s/$OLDLBUFFER//}"
# eval $STRING
# STRING="RRBUFFER=\${RBUFFER:s/$OLDRBUFFER/}"
# eval $STRING
# INS="$LLBUFFER$RRBUFFER"
# LBUFFER=$OLDLBUFFER
# repeat $NNUMERIC LBUFFER="$LBUFFER$INS"
# builtin zle .vi-cmd-mode
# unset LLBUFFER RRBUFFER NNUMERIC INS
# bindkey -M viins "" vi-cmd-mode
#}
#zle -N vi-cmd-mode-a
### vi-change (unbound) (c) (unbound)
### Read a movement command from the keyboard, and kill
### from the cursor position to the endpoint of the
### movement. Then enter insert mode. If the command
### is vi-change, change the current line.
vi-change() {
show_mode "INSERT"
builtin zle .vi-change
}
zle -N vi-change
bindkey -M vicmd "c" vi-change
### vi-change-eol (unbound) (C) (unbound)
### Kill to the end of the line and enter insert mode.
vi-change-eol() {
show_mode "INSERT"
builtin zle .vi-change-eol
}
zle -N vi-change-eol
bindkey -M vicmd "C" vi-change-eol
### vi-change-whole-line (unbound) (S) (unbound)
### Kill the current line and enter insert mode.
vi-change-whole-line() {
show_mode "INSERT"
builtin zle .vi-change-whole-line
}
zle -N vi-change-whole-line
bindkey -M vicmd "S" vi-change-whole-line
### vi-insert (unbound) (i) (unbound)
### Enter insert mode.
vi-insert() {
show_mode "INSERT"
builtin zle .vi-insert
}
zle -N vi-insert
bindkey -M vicmd "i" vi-insert
### vi-insert-bol (unbound) (I) (unbound)
### Move to the first non-blank character on the line
### and enter insert mode.
vi-insert-bol() {
show_mode "INSERT"
builtin zle .vi-insert-bol
}
zle -N vi-insert-bol
bindkey -M vicmd "I" vi-insert-bol
### vi-open-line-above (unbound) (O) (unbound)
### Open a line above the cursor and enter insert mode.
vi-open-line-above() {
show_mode "INSERT"
builtin zle .vi-open-line-above
}
zle -N vi-open-line-above
bindkey -M vicmd "O" vi-open-line-above
### vi-open-line-below (unbound) (o) (unbound)
### Open a line below the cursor and enter insert mode.
vi-open-line-below() {
show_mode "INSERT"
builtin zle .vi-open-line-below
}
zle -N vi-open-line-below
bindkey -M vicmd "o" vi-open-line-below
### vi-substitute (unbound) (s) (unbound)
### Substitute the next character(s).
vi-substitute() {
show_mode "INSERT"
builtin zle .vi-substitute
}
zle -N vi-substitute
bindkey -M vicmd "s" vi-substitute
### vi-replace (unbound) (R) (unbound)
### Enter overwrite mode.
###
vi-replace() {
show_mode "REPLACE"
builtin zle .vi-replace
}
zle -N vi-replace
bindkey -M vicmd "R" vi-replace
### vi-cmd-mode (^X^V) (unbound) (^[)
### Enter command mode; that is, select the `vicmd'
### keymap. Yes, this is bound by default in emacs
### mode.
vi-cmd-mode() {
show_mode "NORMAL"
builtin zle .vi-cmd-mode
}
zle -N vi-cmd-mode
bindkey -M viins "" vi-cmd-mode
##function zle-line-init zle-keymap-select {
##RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}"
##RPS2=$RPS1
##zle reset-prompt
##}
##zle -N zle-line-init
##zle -N zle-keymap-select
### vi-oper-swap-case
### Read a movement command from the keyboard, and swap
### the case of all characters from the cursor position
### to the endpoint of the movement. If the movement
### command is vi-oper-swap-case, swap the case of all
### characters on the current line.
###
bindkey -M vicmd "g~" vi-oper-swap-case
Jump to Line
Something went wrong with that request. Please try again.