From 2ee0a576e31d80022a415840ec70c15ac6f993a7 Mon Sep 17 00:00:00 2001 From: Kevin Date: Fri, 28 Mar 2014 07:36:19 -0400 Subject: [PATCH] Added and to normal mode, doing the same thing as in visual, :wsudo and :esudo can now be run with :sudow and :sudoe, fixed a few issues where gvim settings wouldn't be enabled if gvim was started using :gui in command mode, = now does what + does so you can use - and + without holding shift for the + part, the ctrl/shift up/down/left/right + h/j/k/l stuff now works the same for both using the behaviour I suspect most people will expect from them, a 'lot' of behaviour that didn't work in tmux should now work provided tmux is using xterm-keys and has its $TERM set to screen*, a bunch of new default settings have been added to settings.vim (though they're mostly subtle or behind the scenes tweaks) and it's commented and organized better now too, and the gvim menubar no longer appears by default (but you can toggle it with ) --- vim/bundle/SudoEdit.vim | 2 +- vim/bundle/emmet-vim | 2 +- vim/bundle/vim-pathogen | 2 +- vim/config/keyboard.vim | 78 +++++++++++++++++++++++++----------- vim/config/settings.vim | 88 ++++++++++++++++++++++------------------- 5 files changed, 105 insertions(+), 67 deletions(-) diff --git a/vim/bundle/SudoEdit.vim b/vim/bundle/SudoEdit.vim index 750f728..6515e65 160000 --- a/vim/bundle/SudoEdit.vim +++ b/vim/bundle/SudoEdit.vim @@ -1 +1 @@ -Subproject commit 750f7286c10e42cab2663a4a1bc38ae13b105a34 +Subproject commit 6515e65b9ef467d0ce542e5515a5f39aa36ae963 diff --git a/vim/bundle/emmet-vim b/vim/bundle/emmet-vim index 0511be8..5916ad2 160000 --- a/vim/bundle/emmet-vim +++ b/vim/bundle/emmet-vim @@ -1 +1 @@ -Subproject commit 0511be8ac531bd8a934d31849e1a3e47139f0560 +Subproject commit 5916ad27fa2cc34bf5ab79175715a42e4c7bb4eb diff --git a/vim/bundle/vim-pathogen b/vim/bundle/vim-pathogen index 5b5bee9..099b918 160000 --- a/vim/bundle/vim-pathogen +++ b/vim/bundle/vim-pathogen @@ -1 +1 @@ -Subproject commit 5b5bee9c44f5d24dc7499b92efd5ed8eac305f04 +Subproject commit 099b9181413b81deb49e87d6c787d6cfe8b43ea5 diff --git a/vim/config/keyboard.vim b/vim/config/keyboard.vim index 98680d9..6c7f8a9 100644 --- a/vim/config/keyboard.vim +++ b/vim/config/keyboard.vim @@ -1,4 +1,4 @@ -"===========================" + " Keyboard Configuration: " "===========================" " @@ -11,14 +11,17 @@ " ds" | (N) -> delete surrounding "" " " Mappings: +" = | (N) -> move to the first character on the next line " | (A) -> scroll right " | (A) -> scroll left " | (A) -> unbind this from vim so xorg can paste " | (A) -> open a new tab " | (A) -> go to the next open tab " | (A) -> go to the previous open tab -" | (V) -> indent a block in visual mode -" | (V) -> unindent a block in visual mode +" | (V) -> indent all the lines currently selected +" | (N) -> indent the current line +" | (V) -> unindent all the lines currently selected +" | (N) -> unindent the current line " \\ | (N) -> show spelling suggestions popup for selection " ` | (N) -> toggle the nerdtree sidebar " ~ | (N) -> toggle the tagbar sidebar @@ -55,19 +58,22 @@ " | (N) -> undo the most recent match selection " " GVim Mappings: -" | (A) -> toggle the menu -" | (A) -> toggle the toolbar -" | (A) -> toggle the scrollbar +" | (A) -> toggle the menu +" | (A) -> toggle the toolbar +" | (A) -> toggle the scrollbar " " Aliases: -" :wsudo | (N) -> :SudoWrite (write the file as root using sudo) -" :esudo | (N) -> :SudoRead (read a file as root using sudo) +" :wsudo & :sudow | (N) -> :SudoWrite (write the file as root using sudo) +" :esudo & :sudoe | (N) -> :SudoRead (read a file as root using sudo) " " Notes: " *by the default key is: \ " "MAPPINGS: GENERAL KEYBINDINGS AND REBINDINGS {{{ + "map = to + so shift doesn't need to be held to use its functionality + nnoremap = + + "hold shift to enable middle-click paste noremap noremap! @@ -79,6 +85,8 @@ "tab and untabbing selected blocks vnoremap >gv vnoremap v>gv + nnoremap v "press backslash twice on a mispelled word for suggestions nnoremap \\ ea @@ -98,15 +106,9 @@ vnoremap ':set number!v' "toggle line wrapping (and bottom bar if using the gui) - if !has("gui_running") - nnoremap ':set wrap!' - inoremap ':set wrap!' - vnoremap ':set wrap!' - else - nnoremap ':set wrap! go'.'-+'[&wrap]."=b\r" - inoremap ':set wrap! go'.'-+'[&wrap]."=b\ra" - vnoremap ':set wrap! go'.'-+'[&wrap]."=b\rv" - endif + nnoremap ':set wrap! go'.'-+'[&wrap]."=b\r" + inoremap ':set wrap! go'.'-+'[&wrap]."=b\ra" + vnoremap ':set wrap! go'.'-+'[&wrap]."=b\rv" "toggle the cursor line and column nnoremap ':set cursorline! cursorcolumn!' @@ -131,25 +133,25 @@ nnoremap ':FixWhitespace' "remap keys to scroll through text - nnoremap gg + nnoremap gg0 nnoremap gg0 - nnoremap G + nnoremap G$ nnoremap G$ nnoremap $ nnoremap $ nnoremap ^ - nnoremap 0 + nnoremap ^ "map remap keys to select text nnoremap gg0vG$ - nnoremap vgg + nnoremap vgg0 nnoremap vgg0 - nnoremap vG + nnoremap vG$ nnoremap vG$ nnoremap v$ nnoremap v$ nnoremap v^ - nnoremap v0 + nnoremap v^ "}}} "PLUGIN KEYBINDINGS {{{ @@ -175,16 +177,44 @@ nmap OF imap OF endif + + "tmux will send xterm-style keys when xterm-keys is on + if &term =~ '^screen' && exists('$TMUX') + execute "set =\e[1;*A" + execute "set =\e[1;*B" + execute "set =\e[1;*C" + execute "set =\e[1;*D" + execute "set =\e[1;*H" + execute "set =\e[1;*F" + execute "set =\e[2;*~" + execute "set =\e[3;*~" + execute "set =\e[5;*~" + execute "set =\e[6;*~" + execute "set =\e[1;*P" + execute "set =\e[1;*Q" + execute "set =\e[1;*R" + execute "set =\e[1;*S" + execute "set =\e[15;*~" + execute "set =\e[17;*~" + execute "set =\e[18;*~" + execute "set =\e[19;*~" + execute "set =\e[20;*~" + execute "set =\e[21;*~" + execute "set =\e[23;*~" + execute "set =\e[24;*~" + endif "}}} "GVIM: MAPPINGS FOR GUI ELEMENTS {{{ - "map toggles for the menu, toolbar and scrollbar + "map toggles for the menu, toolbar and vertical scrollbar noremap ":if &go=~#'m'set go-=melseset go+=mendif" noremap ":if &go=~#'T'set go-=Telseset go+=Tendif" noremap ":if &go=~#'r'set go-=relseset go+=rendif" "}}} "ALIASES: COMMAND SHORTCUTS {{{ + cabbrev sudow SudoWrite cabbrev wsudo SudoWrite + cabbrev sudoe SudoRead cabbrev esudo SudoRead "}}} diff --git a/vim/config/settings.vim b/vim/config/settings.vim index 588e4dd..095c93f 100644 --- a/vim/config/settings.vim +++ b/vim/config/settings.vim @@ -3,18 +3,58 @@ "===============================" "COMPATIBILITY SETTINGS: DOCUMENT AND ENVIRONMENT SETTINGS {{{ - set nocompatible "enable vim specific capabilities" - set lazyredraw "only redraw what needs to be redrawn" - set encoding=utf-8 "set encoding" - set fileformats=unix,dos,mac "set compatible line endings in order of preference" + set nocompatible "enable vim specific capabilities + set hidden "tells vim to track things like undo history while a buffer is in the background + set encoding=utf-8 "set encoding + set fileformats=unix,dos,mac "set compatible line endings in order of preference + set backspace=indent,eol,start "enables backspacing + set mouse=a "enables extended mouse capabilities + set clipboard=unnamedplus "enable copy/paste support between vim and the environment's clipboard + + set lazyredraw "only redraw what needs to be redrawn + set ttyfast "assume a fast connection to the terminal for better rendering if $TERM =~ '^linux' set t_Co=8 "use 8 colours when a vterm is detected elseif !has("gui_running") set t_Co=256 "assume 256 colours when any other terminal is detected + set ttymouse=xterm2 "sets the type of mouse to one we can expect in most gui envs endif "}}} +"GENERAL: ANYTHING THAT DOESN'T FIT ELSEWHERE {{{ + set number "enable line numbers + set nowrap "disable line wrapping + set cursorline cursorcolumn "enable row/column highlighting + set visualbell "notify visually instead of with an audible bell + set splitright "add new tiles on the right (and not left) when added + set scrolloff=1 sidescrolloff=1 "start scrolling if the cursor is one position away from the edge + set list listchars=tab:>-,trail:- "display tabs as >--- and trailing spaces as - + set autochdir "current dir is file dir + set history=250 "undo history + set whichwrap=b,s,<,>,[,] "allow the cursor to wrap lines + set textwidth=0 "set an unlimited text width before breaking the line when line breaks are enabled + set nolinebreak "disable linebreaks, though this will be overridden by filetype plugins + set showmatch "show matching open bracket when closed bracket is inserted + set matchtime=5 "the amount of time the matching bracket will highlight + set smarttab expandtab autoindent tabstop=4 shiftwidth=4 "configure tabs + set laststatus=2 showcmd statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v] "statusline init and config + set hlsearch incsearch ignorecase smartcase "configure search + + "load the system version of matchit if another hasn't already been + if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# '' + runtime! macros/matchit.vim + endif + + "enable tab completion in command mode and configure how it handles extensions + set completeopt=longest,menuone + set wildmenu + set wildmode=list:longest,full + set wildignore=*.dll,*.o,*.obj,*.bak,*.exe,*.pyc,*.jpg,*.gif,*.png + set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc +"}}} + + "SYNTAX: INDENTING, HIGHLIGHTING, FOLDING {{{ filetype plugin indent on syntax on "turn syntax highlighting on @@ -33,47 +73,15 @@ au BufNewFile,BufRead ircd.conf setf javascript "set syntax for *ircd.conf to javascript "}}} -"GENERAL: ANYTHING THAT DOESN'T FIT ELSEWHERE {{{ - set cursorline cursorcolumn "enable row/column highlighting - set splitright "add new tiles on the right (and not left) when added - set scrolloff=1 sidescrolloff=1 "how many vertical and horizontal characters left before scrolling - set number "enable line numbers - set list listchars=tab:>-,trail:- "display whitespace - set nowrap "disable line wrapping - set autochdir "current dir is file dir - set backspace=indent,eol,start "enables backspacing - set history=75 "undo history - set mouse=a "enables mouse - set whichwrap=b,s,<,>,[,] "allow the cursor to wrap lines - set clipboard=unnamedplus "enable copy/paste support between vim and xorg's middle-click style clipboard - set textwidth=0 "the default width text will go before breaking when line breaks are enabled - set nolinebreak "disable linebreaks, though this will be overridden by filetype plugins - set showmatch "show matching open bracket when closed bracket is inserted - set matchtime=5 "the amount of time the matching bracket will highlight - set smarttab expandtab autoindent tabstop=4 shiftwidth=4 "configure tabs - set laststatus=2 showcmd statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v] "statusline init and config - set hlsearch incsearch ignorecase smartcase "configure search +"GVIM: GUI CONFIG OPTIONS {{{ set guicursor+=a:blinkon0 "disable the blinking cursor - "load the system version of matchit if another hasn't already been - if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# '' - runtime! macros/matchit.vim - endif - - "enable menu tab completion, configure its behaviour and set configure suffixes to reduce priority for and ignore" - set completeopt=longest,menuone - set wildmenu - set wildmode=list:longest,full - set wildignore=*.dll,*.o,*.obj,*.bak,*.exe,*.pyc,*.jpg,*.gif,*.png - set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc -"}}} - -"GVIM: GUI CONFIG OPTIONS {{{ set guioptions-=T "remove the toolbar + set guioptions-=m "remove the toolbar if &wrap - set go-=b "disable the bottom scrollbar iff text wrapping is enabled + set go-=b "disable the bottom scrollbar on launch iff text wrapping is enabled else - set go+=b "enable the bottom scrollbar iff text wrapping is disabled + set go+=b "enable the bottom scrollbar on launch iff text wrapping is disabled endif "}}}