Skip to content
Browse files

Set vi mode as default in zsh

And add a bunch of emacs-style shortcuts so as not to stress the muscle
memory too much.
  • Loading branch information
pjg committed Sep 23, 2012
1 parent c5d35d4 commit a931077e7ba65dec89e132ed58fdf1e763c33c61
Showing with 47 additions and 3 deletions.
  1. +47 −3 .zshrc
50 .zshrc
@@ -194,12 +194,12 @@ unsetopt nomatch


# VIM style keybindings by default
bindkey -v

# make backward-word and forward-word move to each word separated by a '/'
export WORDCHARS=''

# emacs style keybindings by default
bindkey -e

# turn off terminal driver flow control (CTRL+S/CTRL+Q) (if we are a terminal)
if [ -t 0 ]; then
stty -ixon -ixoff
@@ -237,6 +237,50 @@ case "$TERM" in

# shift + tab
bindkey '^[[Z' reverse-menu-complete

bindkey -M viins '^a' beginning-of-line
bindkey -M viins '^e' end-of-line
bindkey -M viins '^k' kill-line
bindkey -M viins '^r' history-incremental-pattern-search-backward
bindkey -M viins '^s' history-incremental-pattern-search-forward
bindkey -M viins '^p' up-line-or-history
bindkey -M viins '^n' down-line-or-history
bindkey -M viins '^y' yank
bindkey -M viins '^w' backward-kill-word
bindkey -M viins '^u' backward-kill-line
bindkey -M viins '^h' backward-delete-char
bindkey -M viins '^?' backward-delete-char
bindkey -M viins '^_' undo
bindkey -M viins '^x^r' redisplay
bindkey -M viins '\eOH' beginning-of-line # Home
bindkey -M viins '\eOF' end-of-line # End
bindkey -M viins '\e[2~' overwrite-mode # Insert
bindkey -M viins '\ef' forward-word # Alt-f
bindkey -M viins '\eb' backward-word # Alt-b
bindkey -M viins '\ed' kill-word # Alt-d

bindkey -M vicmd '^a' beginning-of-line
bindkey -M vicmd '^e' end-of-line
bindkey -M vicmd '^k' kill-line
bindkey -M vicmd '^r' history-incremental-pattern-search-backward
bindkey -M vicmd '^s' history-incremental-pattern-search-forward
bindkey -M vicmd '^p' up-line-or-history
bindkey -M vicmd '^n' down-line-or-history
bindkey -M vicmd '^y' yank
bindkey -M vicmd '^w' backward-kill-word
bindkey -M vicmd '^u' backward-kill-line
bindkey -M vicmd '/' vi-history-search-forward
bindkey -M vicmd '?' vi-history-search-backward
bindkey -M vicmd '^_' undo
bindkey -M vicmd '\ef' forward-word # Alt-f
bindkey -M vicmd '\eb' backward-word # Alt-b
bindkey -M vicmd '\ed' kill-word # Alt-d
bindkey -M vicmd '\e[5~' history-beginning-search-backward # PageUp
bindkey -M vicmd '\e[6~' history-beginning-search-forward # PageDown

0 comments on commit a931077

Please sign in to comment.
You can’t perform that action at this time.