Skip to content

Instantly share code, notes, and snippets.

@LIttleAncientForestKami
Last active August 27, 2016 18:22
Show Gist options
  • Save LIttleAncientForestKami/7021c09496a570d3d8b9ce9c781e4313 to your computer and use it in GitHub Desktop.
Save LIttleAncientForestKami/7021c09496a570d3d8b9ce9c781e4313 to your computer and use it in GitHub Desktop.
Vim all the things!
# Vimperator
firefox https://addons.mozilla.org/pl/firefox/addon/vimperator/
# Vim with clipboard
sudo apt-get install vim-gnome
# Terminal (ZSH, TCSH)
## http://dougblack.io/words/zsh-vi-mode.html
bindkey -v
# Bash
echo "For Bash it's: set -o vi"
export KEYTIMEOUT=10 # default is 40, 0.4 second
bindkey -M viins 'jk' vi-cmd-mode # @todo - THIS DOES NOT WORK?
bindkey -M viins '^k' kill-line
# perhaps...
bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
bindkey '^r' history-incremental-search-backward
# show which Vim mode we are in (may want to change in prompt)
precmd() {
RPROMPT=""
}
zle-keymap-select() {
RPROMPT=""
[[ $KEYMAP = vicmd ]] && RPROMPT="(COMMAND MODE)"
() { return $__prompt_status }
zle reset-prompt
}
zle-line-init() {
typeset -g __prompt_status="$?"
}
zle -N zle-keymap-select
zle -N zle-line-init
# GNU readline with VI shortcuts
# works where readline is used, like in MySQL or pgsql
# http://vim.wikia.com/wiki/Use_vi_shortcuts_in_terminal
vim .input.rc
# Use Vi, not Emacs, style editing
set editing-mode vi
# Show all completions as soon as I press tab, even if there's more than one
set show-all-if-ambiguous on
# Ignore case
set completion-ignore-case on
# on menu-complete, first display the common prefix, then cycle through the
# options when hitting TAB
menu-complete-display-prefix on
###########################################################
# Keymaps for when we're in command mode (e.g., after hitting ESC)
set keymap vi-command
# Insert the arguments from the last command
"p": "i !!*\r"
# When hitting option-up/option-down, cycle through the previous commands
# which start with the prefix you've entered, rather than just cycling through
# the last entered commands.
# In OS X's Terminal.app preferences, I have 'Use option as meta key' off, and
# have mapped "option cursor up" to "\033\033[A" and "option cursor down" to
# "\033\033[B".
# Feel free to bind to whatever you want. Delete the first '\e' in the keymap
# to set plain up/down to do a history search by default.
"\e\e[A": history-search-backward
"\e\e[B": history-search-forward
###########################################################
# Keymaps for when we're in insert (i.e., typing stuff in) mode
set keymap vi-insert
# Pressing tab will list all completions & select the first one. Pressing it
# again will cycle through available completions.
TAB: menu-complete
# Shift-TAB cycles completions backward
"\e[Z": menu-complete-backward
# Option-up/option-down should also apply to insert mode
"\e\e[A": history-search-backward
"\e\e[B": history-search-forward
# Needed because binding 'p' in command mode above wipes its insert mode
# function, too. This fixes that, and will insert 'p' when you type 'p'.
"p": self-insert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment