Created
November 4, 2010 00:21
-
-
Save JoshMock/661941 to your computer and use it in GitHub Desktop.
Vim settings
This file contains 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
" Pathogen settings to auto-load new plugins (http://www.vim.org/scripts/script.php?script_id=2332) | |
filetype off | |
call pathogen#runtime_append_all_bundles() | |
call pathogen#helptags() | |
filetype plugin indent on | |
"Enable filetypes | |
filetype on | |
filetype plugin on | |
filetype indent on | |
syntax on | |
" turn off vi compatibility | |
set nocompatible | |
" prevents security exploits dealing with modelines in files | |
set modelines=0 | |
" expands tabs to 4 spaces, etc | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
set expandtab | |
" Indentation rules | |
set autoindent | |
set smartindent | |
" UTF-8 text encoding by default | |
set encoding=utf-8 | |
" Show TextMate-like whitespace chars for tab and end of line | |
set list | |
set listchars=tab:▸\ ,eol:¬ | |
" Random stuff from http://stevelosh.com/blog/2010/09/coming-home-to-vim/#making-vim-more-useful | |
set scrolloff=3 | |
set showmode | |
set visualbell | |
set cursorline | |
set ttyfast | |
set backspace=indent,eol,start | |
" Auto cd to current file's directory | |
autocmd BufEnter * lcd %:p:h | |
" More useful command-line-like tab completion | |
set wildmenu | |
"Auto-completion menu | |
set wildmode=list:longest | |
"Show command in bottom right portion of the screen | |
set showcmd | |
" Display current cursor position in lower right corner | |
set ruler | |
" Switch between buffers without saving | |
set hidden | |
" Always show status line | |
set laststatus=2 | |
" Remap leader key from \ to , | |
let mapleader = "," | |
" Remaps / search key to use standard regex instead of vim regex | |
nnoremap / /\v | |
vnoremap / /\v | |
" If searching all lowercase, search case-insensitive. | |
" If any characters are uppercase, search case-sensitive. | |
set ignorecase | |
set smartcase | |
" %s/foo/bar/ will assume %s/foo/bar/g | |
set gdefault | |
" Highlight results as you search | |
set incsearch | |
set showmatch | |
set hlsearch | |
" Clear a search by typing ,<space> | |
nnoremap <leader><space> :noh<cr> | |
" Turn on line numbers by typing ,num | |
nnoremap <leader>num :set number<cr> | |
nnoremap <leader>rnum :set relativenumber<cr> | |
nnoremap <leader>nonum :set nonumber<cr>:set norelativenumber<cr> | |
" Remaps % to tab to navigate matching brackets | |
nnoremap <tab> % | |
vnoremap <tab> % | |
" Line-wrapping options | |
set wrap | |
set textwidth=79 | |
set formatoptions=qrn1 | |
" Use <leader>H to toggle highlighting lines over 80 chars | |
nnoremap <leader>H :call<SID>LongLineHLToggle()<cr> | |
hi OverLength ctermbg=none cterm=none | |
match OverLength /\%>80v/ | |
fun! s:LongLineHLToggle() | |
if !exists('w:longlinehl') | |
let w:longlinehl = matchadd('ErrorMsg', '.\%>80v', 0) | |
echo "Long lines highlighted" | |
else | |
call matchdelete(w:longlinehl) | |
unl w:longlinehl | |
echo "Long lines unhighlighted" | |
endif | |
endfunction | |
" Backup directories | |
set backupdir=~/.vim/tmp/backup/ | |
set directory=~/.vim/tmp/swap/ | |
set backup | |
" Disables arrow keys in normal mode to enforce use of hjkl | |
nnoremap <up> <nop> | |
nnoremap <down> <nop> | |
nnoremap <left> <nop> | |
nnoremap <right> <nop> | |
inoremap <up> <nop> | |
inoremap <down> <nop> | |
inoremap <left> <nop> | |
inoremap <right> <nop> | |
nnoremap j gj | |
nnoremap k gk | |
" Remap F1 to Esc to avoid accidentally opening help docs | |
inoremap <F1> <ESC> | |
nnoremap <F1> <ESC> | |
vnoremap <F1> <ESC> | |
" Remap jj to do same thing as <ESC> when in insert mode | |
inoremap jj <ESC> | |
" Sets font to Inconsolata (http://www.levien.com/type/myfonts/inconsolata.html) size 14 | |
set guifont=Inconsolata:h14 | |
" Sets color scheme to jellybeans (https://github.com/nanotech/jellybeans.vim) | |
colorscheme jellybeans | |
" NERDTree (https://github.com/scrooloose/nerdtree) | |
let NERDTreeIgnore=['\.pyc$'] | |
" Typing ,npy automatically opens Python tree | |
nnoremap <leader>npy :NERDTree python<cr> | |
" Typing ,nph automatically opens PHP tree | |
nnoremap <leader>nph :NERDTree php<cr> | |
" Typing ,nt toggles tree between open or closed | |
nnoremap <leader>nt :NERDTreeToggle<cr> | |
" Automatically fold code based on indents | |
set foldmethod=indent | |
" Settings for Indent Guides plugin (https://github.com/nathanaelkane/vim-indent-guides) | |
let g:indent_guides_guide_size = 1 | |
let g:indent_guides_start_level = 2 | |
" Check syntax | |
autocmd BufRead *.py set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\" | |
autocmd BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m | |
autocmd BufRead *.py nmap <F5> :!python %<CR> | |
" Crontab uses tmp files to edit, so backup rules must change. (See | |
" .bash_profile for $VIM_CRONTAB alias stuff.) | |
if $VIM_CRONTAB == "true" | |
set nobackup | |
set nowritebackup | |
endif | |
" " autocomplete brackets and quotes | |
" inoremap { {}<Left> | |
" inoremap {<CR> {<CR>}<Esc>O | |
" inoremap {{ { | |
" inoremap {} {} | |
" | |
" inoremap ( ()<Left> | |
" inoremap (<CR> (<CR>)<Esc>O | |
" inoremap (( ( | |
" inoremap () () | |
" | |
" inoremap [ []<Left> | |
" inoremap [<CR> [<CR>]<Esc>O | |
" inoremap [[ [ | |
" inoremap [] [] | |
" | |
" inoremap " ""<Left> | |
" inoremap "" "" | |
" " Python style triple quotes | |
" inoremap """ """<CR><CR>"""<Esc>ki<Tab> | |
" inoremap ' ''<Left> | |
" inoremap '' '' | |
" " Python style triple quotes | |
" inoremap ''' '''<CR><CR>'''<Esc>ki<Tab> | |
" Remap ,d to close current buffer | |
nnoremap <leader>d :bd<cr> | |
" Remap ,w to switch splits | |
nnoremap <leader>w <C-w>w<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment