-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
179 lines (139 loc) · 5.53 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
set nocompatible " Vim settings over old Vi, must be first!
set backspace=indent,eol,start " allow backspacing everything in insert mode
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif
" Pathogen initialization i.e. load bundle
call pathogen#infect()
" -----------------------------------------------------------------------------
" VISUAL SETTINGS
" -----------------------------------------------------------------------------
" Enable 256 colors when not using a GUI.
if !has("gui_running")
set t_Co=256
endif
colorscheme wombat256 " Default color scheme
set number " Line numbering
set cursorline " Highlight current line
" Visual color column at +1 of text width
if exists("&colorcolumn")
set colorcolumn=+1
highlight ColorColumn ctermbg=8 guibg=gray35
endif
" Style special list characters (i.e. tab, EOL)
hi NonText ctermfg=darkgray guifg=darkgray
hi SpecialKey ctermfg=darkgray guifg=darkgray ctermbg=NONE guibg=NONE
" Underline spelling mistakes
if version >= 700
hi SpellBad guisp=red gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=underline
hi SpellCap guisp=yellow gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=underline
hi SpellRare guisp=blue gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=underline
hi SpellLocal guisp=orange gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=underline
endif
" -----------------------------------------------------------------------------
" COMMANDS / SHORTCUTS
" -----------------------------------------------------------------------------
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" Allow SHIFT+h and SHIFT+l to cycle tabs
map <S-h> gT
map <S-l> gt
" F2 shortcut to open nerdtree file browser
map <F2> :NERDTreeToggle<CR>
" Shortcut to strip all trailing whitespace
nnoremap <silent> <F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" Handier command mode shortcut
imap å <ESC>
vmap å <ESC>
smap å <ESC>
" Shortcut to rapidly toggle `set list`
set listchars=tab:▸\ ,eol:¬
nmap <leader>l :set list!<CR>
" Allow :W to write to file (capital w)
command! W write
" Easy split navigation (http://vimbits.com/bits/10)
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Toggle spell-checking with function key
map <F3> :setlocal spell! spelllang=en_us<CR>
" Toggle extraneous whitespace highlighting
map <F4> :ToggleBadWhitespace<CR>
" Clear CtrlP cache
nmap <leader>p :CtrlPClearAllCaches<CR>
" -----------------------------------------------------------------------------
" PLUGIN SETTINGS
" -----------------------------------------------------------------------------
" Ezbar: Enable
let g:ezbar_enable = 1
set laststatus=2
" NERDTree and CtrlP: ignore certain file types
set wildignore+=*~,.git,*.pyc,*.class
let NERDTreeIgnore = ['\.pyc$', '\.class$', '\~$']
" delimitMate: disable on HTML/XML files
au FileType html,xml,gsp let b:delimitMate_autoclose = 0
" ctrlp: ignore folders
let g:ctrlp_custom_ignore = 'node_modules'
" -----------------------------------------------------------------------------
" ADDITIONAL FEATURES
" -----------------------------------------------------------------------------
set clipboard=unnamedplus " Yanks go to OS clipboard instead
set encoding=utf-8 " Default encoding UTF-8
set backspace=indent,eol,start " Allow backspacing everything in insert mode
" Default formatting options
set expandtab
set textwidth=79
set tabstop=4
set shiftwidth=4
set softtabstop=4
set formatoptions-=t " Don't force newlines at text width bounds
" Don't litter temporary files around filesystem, instead put them all in a
" single temp folder.
set backupdir=~/.vim_tmp