Skip to content

Instantly share code, notes, and snippets.

@jcowles
Last active August 29, 2020 17:52
Show Gist options
  • Save jcowles/ba29ce84dbf3c90fb9c72780354f2a5d to your computer and use it in GitHub Desktop.
Save jcowles/ba29ce84dbf3c90fb9c72780354f2a5d to your computer and use it in GitHub Desktop.
My default settings to modernize Vim behavior
" On Linux/OSX this is ~/.vimrc
" On windows this is ~/_vimrc
" Don't drop garbage files everywhere.
" Note that this disables vim backup files, which I'm cool with, but
" maybe you're not.
:set nobackup
" Prepend (^=) the windows temp dir as the place to keep swap files.
" The // tells vim to use the absolute path to avoid collisions.
" These files will still allow you to recover data after a crash, so
" I'm not sure why the backup (above) is also needed.
set directory^=C:/Windows/Temp//
" Standard Copy/Paste key bindings.
" CTRL-X and SHIFT-Del are Cut
vnoremap <C-X> "+x
vnoremap <S-Del> "+x
" CTRL-C and CTRL-Insert are Copy
vnoremap <C-C> "+y
vnoremap <C-Insert> "+y
" CTRL-V and SHIFT-Insert are Paste
map <C-V> "+gP
map <S-Insert> "+gP
cmap <C-V> <C-R>+
cmap <S-Insert> <C-R>+
" CTRL+Z => Undo
nmap <C-Z> u
" Enable line numbers and syntax highlighting.
:set number
:syntax on
" Use a true type font!
:set guifont=Lucida_Console:h10
" Make backspace work like a modern editor.
:set backspace=indent,eol,start
filetype plugin indent on
" Gold standard: 2-spaces per tab, no tab characters.
set tabstop=2 softtabstop=0 expandtab shiftwidth=2 smarttab
" Make shift+arrow keys work as expected.
nmap <S-Up> v<Up>
nmap <S-Down> v<Down>
nmap <S-Left> v
nmap <S-Right> v
nmap <S-End> v<End>
nmap <S-Home> v<Home>
" If inserting and shift+arrow is pressed, stop inserting
" and jump into visual mode.
imap <S-Up> <ESC>v<Up>
imap <S-Down> <ESC>v<Down>
imap <S-Left> <ESC>v
imap <S-Right> <ESC><Right>v
imap <S-End> <ESC>v<End>
imap <S-Home> <ESC>v<Home>
"When in visual mode, if enter/return is pressed, exit visual
"and break the line and return to normal mode.
vmap <Return> <ESC>xi<Return><ESC>
" Shift up/down in visual mode should just select the next/prev
" line, not jump to the top/bottom of the document.
vmap <S-Up> <Up>
vmap <S-Down> <Down>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment