-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
252 lines (216 loc) · 6.35 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
" my ([email protected]) .vimrc
"
" started with a copy of distributed vimrc_example.vim
"
" i'm a recent vim convert (2013) and some of my choices
" are likely explained by my past shell/editor history:
"
" shell: Bourne => Korn => bash, always with emacs bindings
"
" editor: CBM 4000-series
" WordStar (MS-DOS)
" DEC EDT (RSX11M+)
" EDT (SCO Xenix/Unix)
" joe (SCO Unix w/EDT keymapping)
" joe (SCO Unix/Linux/MacOSX w/standard keymapping)
" vim (Linux, MacOSX)
" everything starts with vim settings
set nocompatible
" remap leader
let mapleader=";"
" use vundle for addon management
filetype off
set runtimepath +=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'airblade/vim-gitgutter'
Plugin 'ap/vim-css-color'
Plugin 'bling/vim-airline'
Plugin 'c9s/perlomni.vim'
Plugin 'gmarik/Vundle.vim'
Plugin 'hail2u/vim-css3-syntax'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'marijnh/tern_for_vim'
Plugin 'mileszs/ack.vim'
Plugin 'mustache/vim-mustache-handlebars'
Plugin 'pangloss/vim-javascript'
Plugin 'Raimondi/delimitMate'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'scrooloose/syntastic'
Plugin 'sjl/gundo.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'Valloric/YouCompleteMe'
Plugin 'vim-perl/vim-perl'
call vundle#end()
" configure airline behavior
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_detect_modified = 1
let g:airline_detect_paste = 1
let g:airline_detect_iminsert = 1
let g:airline_section_z = '%3c [0x%03B] %3p%% %2(%{winnr()}%)'
let g:airline_theme = 'dark'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_idx_mode = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#tab_nr_type = 1
" configure easymotion behavior
let g:EasyMotion_do_mapping = 0
let g:EasyMotion_keys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ;'
let g:EasyMotion_smartcase = 1
let g:EasyMotion_use_upper = 1
" configure gitgutter behavior
set signcolumn=yes
" configure gundo behavior
let g:gundo_close_on_revert=1
" configure nerdtree behaviour
let g:NERDTreeShowBookmarks=1
let g:NERDTreeShowHidden=1
" configure syntastic behavior
let g:syntastic_aggregate_errors = 1
let g:syntastic_auto_jump = 3
" configure syntax-specific behavior
filetype plugin indent on
syntax on
" configure color scheme
highlight link EasyMotionTarget VisualNOS
highlight link EasyMotionShade LineNr
highlight LineNr ctermfg=DarkGrey
highlight SignColumn ctermbg=None
set background=dark
" configure mouse behavior
set mouse=a
" configure backspace behavior
set backspace=eol,indent,start
" configure command behavior
set incsearch
set showcmd
set timeoutlen=1000
set ttimeout
set ttimeoutlen=100
set wildmenu
set wildmode=longest:list,full
" configure autocompletion
set complete=.,w,b,u,t,i
set completeopt=longest,menu,preview
" configure backup behavior
let backup_dir = expand('~/.vim/backup')
if filewritable(backup_dir) != 2
call mkdir(backup_dir, 'p')
endif
let &backupdir=backup_dir
set backup
" configure swap behavior
let swap_dir = expand('~/.vim/swap')
if filewritable(swap_dir) != 2
call mkdir(swap_dir, 'p')
endif
let &directory=swap_dir
set swapfile
" configure undo behavior
if has('persistent_undo')
let undo_dir = expand('~/.vim/undo')
if filewritable(undo_dir) != 2
call mkdir(undo_dir, 'p')
endif
let &undodir=undo_dir
set undofile
endif
" configure buffer/window/tab behavior
set confirm
set hidden
set switchbuf=useopen,usetab
set tabpagemax=8
set title
set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)
" configure lastline/linenumber/statusline/tabline behavior
set cursorline
set display+=lastline
set laststatus=2
set noshowmode
set number
set showtabline=2
" configure history/search behavior
set history=100
set hlsearch
set ignorecase
set incsearch
set smartcase
" configure viminfo storage behavior
set viminfo=!,h,'500,<1000,s1000,/1000,:1000
" configure indent/tab behavior
set autoindent
set expandtab
set shiftwidth=4
set smarttab
set softtabstop=4
set tabstop=8
" configure code folding behavior
set foldclose=all
set foldlevelstart=10
set foldmethod=syntax
set foldnestmax=10
" configure scrolling behavior
set scrolloff=4
set scrollopt=ver,hor,jump
" enable paste toggle
set pastetoggle=<ESC>p
" avoid duplicate terminal output for subshell commands
set shellpipe=>
" map keys - NORMAL mode
nnoremap ' `
nnoremap ` '
nnoremap <silent> <Space> :nohlsearch<CR><Space>
nmap <leader><leader> <Plug>(easymotion-sn)
nnoremap <leader>gs :Gstatus<CR>
nnoremap <leader>gu :GundoToggle<CR>
nnoremap <leader>nt :NERDTreeToggle<CR>
nnoremap <leader>sc :SyntasticCheck<CR>
nnoremap <leader>vc :PluginClean<CR>
nnoremap <leader>vu :PluginUpdate<CR>
for i in range(1,9)
execute "nmap <silent> <leader>b" . i . " <Plug>AirlineSelectTab" . i
execute "nnoremap <silent> <leader>t" . i . " " . i . "gt"
execute "nnoremap <silent> <leader>w" . i . " :" . i . "wincmd w<CR>"
endfor
" map keys - INSERT mode
inoremap <ESC>v <ESC>p<C-R>*<ESC>p
" map keys - VISUAL mode
vnoremap <Space> "*y
" command to run perltidy on a range of lines
command -range=% -nargs=* PerlTidy <line1>,<line2>!perltidy
" function to run perltidy on a whole buffer and restore cursor position
function! RunPerlTidy()
let position = line2byte(line("."))
:PerlTidy
execute "goto " . position
endfunction
" function to display help in its own tab for easier reading
function! HelpInTab()
if &buftype == 'help'
execute "normal! \<C-W>T"
endif
endfunction
" function to restore previous cursor position on buffer open
function! RestoreCursorPosition()
if line("'\"") > 0 && line("'\"") <= line("$")
execute "normal! g'\""
endif
endfunction
" local custom autocmds in their own group
augroup local
" clear all commands in this group
autocmd!
" open help buffers in a separate tab
autocmd BufEnter *.txt call HelpInTab()
" restore previous cursor position on buffer read
autocmd BufReadPost * call RestoreCursorPosition()
" map perltidy shortcuts
autocmd FileType perl nnoremap <leader>pt :call RunPerlTidy()<CR>
autocmd Filetype perl vnoremap <leader>pt :PerlTidy<CR>
" choose read-only to avoid simultaneous edits of the same file
autocmd SwapExists * :let v:swapchoice = 'o'
augroup END