Created
November 18, 2011 18:15
-
-
Save weaksauce/1377245 to your computer and use it in GitHub Desktop.
vimrc from hn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" .vimrc | |
" Author: Karl Groll <[email protected]> | |
" | |
" Mostly stolen from Steve Losh | |
" (http://stevelosh.com/blog/2010/09/coming-home-to-vim/) | |
" | |
" Preamble ---------------------------------------------------------------- {{{ | |
filetype off | |
call pathogen#runtime_append_all_bundles() " Enable 'Pathogen' plugin. (Vim plugin manager) | |
filetype plugin on " Load plugin if one exists for current filetype | |
filetype plugin indent on " Load indent plugin if one exists for current ft. Disable auto-indenting | |
set nocompatible " Don't use Vi compatibility | |
" }}} | |
" Basic Options ----------------------------------------------------------- {{{ | |
set encoding=utf-8 " Set encoding inside vim to 32bit UTF-8 encoded Unicode | |
set modelines=0 " Prevent (some) modelines security exploits | |
set autoindent " Copy indent from current line when CR or o/O commands used | |
set copyindent " Autoindent copies indent format of previous line | |
set nosmartindent " Explicity don't try to guess how I want my indents | |
set showmode " Put a message on last line showing edit mode | |
set showcmd " Show partial commands | |
set cursorline " Highlight current row | |
set ttyfast " Improves smoothness w/ multiple windows | |
set ruler " Show ruler at bottom | |
set backspace=indent,eol,start " Nothing can stop the backspace ! | |
set number " Turn on line numbers | |
set laststatus=2 " Always show status bar (w/ filename) | |
set history=1000 " Remember 1000 lines of command line history | |
set undoreload=10000 " Save whole buffer for undo when reloading it | |
set undofile " Specify new location for vim7.3 persistent undo file | |
set undodir=~/.vim/.undo " Put undo history into ~/.vim/undo | |
set backup " turn backups on | |
set backupdir=~/.vim/.backup " Where to keep backup files | |
set directory=~/.vim/.tmp " Where to keep swap files | |
set list listchars=tab:>-,trail:~,extends:>,precedes:< " Show tabs as >- and trailing space as ~ | |
set lazyredraw " Don't redraw screen when executing macros/untyped cmds | |
set splitbelow splitright " Use sane window splitting. To right and below | |
set autoread " Automatically read file when changed outside vim | |
set title " Title of window set to value of 'titlestring' | |
set mouse=a " Use mouse everywhere | |
set noerrorbells " Don't make noise | |
set clipboard+=unnamed " Put contents of unnamed register in system clipboard | |
set foldmethod=syntax " Syntax highlighting items specify folds | |
" }}} | |
" Wildmenu Completion ----------------------------------------------------- {{{ | |
set wildmenu " Enhanced cmd line completion. show possible autocomplete matches | |
set wildmode=full " Complete first full match, next match, etc. | |
set wildignore+=*.git " Don't show version control in autocomplete | |
set wildignore+=*.jpg,*.jpeg,*.png,*.gif " Don't show image binaries | |
" }}} | |
" Tabs, spacing, wrapping ------------------------------------------------- {{{ | |
set tabstop=2 " Tabs count for 2 spaces | |
set shiftwidth=2 " Use 2 spaces for each step of autoindent | |
set softtabstop=2 " Tabs count for 2 spaces in edit mode | |
set expandtab " Expand tabs to spaces | |
set nowrap " Word wrapping off | |
set textwidth=80 " Break line after 80 characters (on whitespace only) | |
" }}} | |
" Colorscheme ------------------------------------------------------------- {{{ | |
syntax on " Syntax highlighting on | |
set background=dark " Changes highlighting to look better on dark bg | |
colorscheme desert | |
" }}} | |
" Search and Movement ----------------------------------------------------- {{{ | |
set ignorecase " Ignore case in searches... | |
set smartcase " ...unless caps explicitly specified | |
set showmatch " Show matching brackets | |
set incsearch " Jump to search results as they're typed | |
set hlsearch " Highlight all search matches | |
set gdefault " Make global flag default when searching | |
set scrolloff=5 " Keep 5 lines of context at the top/bottom | |
set sidescrolloff=5 " Keep 5 lines of context at the sides | |
set virtualedit+=block " Allow cursor to move outside char boundaries (in visual block) | |
" }}} | |
" Misc settings/mappings -------------------------------------------------- {{{ | |
" Resize vim windows when terminal window is resized | |
au VimResized * exe "normal! \<C-W>=" | |
" Change leader key to , (instead of \ by default) | |
let mapleader = "," | |
map <F2> :NERDTreeToggle<cr> | |
" 'jj' exits insert mode | |
inoremap jj <ESC> | |
cnoremap jj <ESC> | |
" H jumps to first non whitespace char on line, L to last | |
noremap H ^ | |
noremap L g_ | |
" <leader><space> clears all highlighting | |
nnoremap <leader><space> :nohlsearch<cr> | |
" Use <leader>w to remove all trailing spaces | |
" Searches for any number of spaces (\s\+$) and replaces it with nothing (//) | |
" The search term still resides in the '/' buffer, so then we clear it ('') | |
nnoremap <leader>w :%s/\s\+$//g<cr>:let @/=''<cr> | |
" Use <leader>rt to retab the file with tabstop=8 | |
" Sets tab width to 8, and then converts all tabs to spaces | |
nnoremap <leader>rt :set ts=8<cr>:%retab<cr> | |
" Map arrow keys to window resizing | |
if bufwinnr(1) | |
map <Up> <C-W>- | |
map <Down> <C-W>+ | |
map <Left> <C-W>< | |
map <Right> <C-W>> | |
endif | |
" Useful for when 'wrap' is set. Instead of moving to the real next line, | |
" j (or k) moves down (or up) to the next *row* of text | |
nnoremap j gj | |
nnoremap k gk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment