-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
403 lines (292 loc) · 10.5 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
"============= Runtime Stuff =============
" probably not necessary, but...
set nocompatible
" change the leader key to ,
let mapleader=","
" use blowfish encryption (stronger than standard)
if v:version >= 703
set cryptmethod=blowfish
endif
" use Inconsolata unless overriden
set gfn=Inconsolata\ Medium\ 12
" windows stuff (ignore on Linux)
if has('win32')
set gfn=Consolas:h13:cANSI " when on Windows use Consolas
" make cygwin the default shell on windows
set shellxquote=
set shellpipe=2>&1\|tee
set shellredir=>%s\ 2>&1
set shellslash
let g:ruby_path = ':C:\Ruby193\bin'
elseif has('mac')
set gfn=Monaco\ 12 " use the Monaco font when on Mac
endif
" Enable UTF-8 support so that I can type polish characters
if has("multi_byte")
" set encoding on terminal if not set
if &termencoding == ""
let &termencoding = &encoding
endif
" force utf-8
set encoding=utf-8
setglobal fileencoding=utf-8 bomb
set fileencodings=ucs-bom,utf-8,latin1
endif
"============= GUI Options =============
if has('gui_running')
set guioptions-=T " disable tool bar
set guioptions-=m " disable menu bar
" make the default window bigger
set lines=45 columns=160
endif
"============= Key Mappings =============
" press ; to issue commands in normal mode (no more shift holding)
nnoremap ; :
" move by screen lines, not by real lines - great for creative writing
nnoremap j gj
nnoremap k gk
nnoremap <up> gk
nnoremap <down> gj
" also in visual mode
vnoremap j gj
vnoremap k gk
vnoremap <up> gk
vnoremap <down> gj
" make up and down arrows work in insert mode
" c-o jumps to normal mode for one command
inoremap <up> <C-O>gk
inoremap <down> <C-O>gj
" insert current date on F10 - useful for dated logs or journals
:nnoremap <F10> "=strftime("%a %b %d, %Y")<CR>P
:inoremap <F10> <C-R>=strftime("%a %b %d, %Y")<CR>
" run ctags on current directory recursively
nnoremap <f6> :!ctags -R<cr>
" pressing \<space> clears the search highlights
nmap <silent> <leader><space> :nohlsearch<CR>
" break a line at cursor
nnoremap <silent> <leader><CR> i<CR><ESC>
" insert a blank line with <leader>o and <leader>O
nnoremap <silent> <leader>o o<ESC>
nnoremap <silent> <leader>O O<ESC>
" use jj to quickly escape to normal mode while typing
inoremap jj <ESC>
" shift Tab to cycle through buffers
nnoremap <S-Tab> :bnext<CR>
" toggle paste mode (to paste properly indented text)
nnoremap <F3> :set invpaste paste?<CR>
set pastetoggle=<F3>
set showmode
" run current PHP file through php interpreter
:autocmd FileType php noremap <leader>p :w!<CR>:!php %<CR>
" run current PHP file through php linter (syntax check) check
:autocmd FileType php noremap <leader>l :!php -l %<CR>
" use \y and \p to copy and paste from system clipboard
noremap <leader>y "+y
noremap <leader>Y "+Y
noremap <leader>p "+p
noremap <leader>P "+P
" automatically jump to last misspelled word and attempt replacing it
noremap <leader>ss [sz=
noremap <leader>aa [sz=1<cr><cr>
" use Ctrl+L in insert mode to correct last misspelled word
inoremap <C-l> <esc>[sz=
noremap <C-i> gi
" Ctrl+Backspace deletes last word
inoremap <C-BS> <esc>bcw
" Ctrl+De; deletes next word
inoremap <C-Del> <esc>wcw
" open my vimrc in a split
command! VIMRC vsplit $MYVIMRC
" now source it
command! SOURCE source $MYVIMRC
" repeated C-r pastes in the contents of the unnamed register
inoremap <C-r><C-r> <C-r>"
" surround the current word with quotes
nnoremap <leader>' ciw"<C-r>""<esc>
nnoremap <leader>, ciw<<C-r>"><esc>
nnoremap <leader>( ciw(<C-r>")<esc>
" surround word/sentence with emp, strong
noremap <leader>e ciw<emp><C-r>"</emp><esc>
noremap <leader>E cis<emp><C-r>"</emp><esc>
noremap <leader>s ciw<strong><C-r>"</strong><esc>
noremap <leader>S cis<strong><C-r>"</strong><esc>
noremap <leader>blk I<blockquote><esc>A</blockquote><esc>
" Markdown bindings
nnoremap <silent> <leader>h1 YpVr=
nnoremap <silent> <leader>h2 YpVr-
noremap <leader>b ciw**<C-r>"**<esc>
noremap <leader>B cis**<C-r>"**<esc>
noremap <leader>i ciw*<C-r>"*<esc>
noremap <leader>I cis*<C-r>"*<esc>
" run current buffer through markdown converter
" you should have the Markdown.pl in your .vim directory for convenience
if filereadable($HOME."/.vim/Markdown.pl")
" run Markdown.pl on current file and dump the output to a .html file
" then attempt to open that file in a web browser
function! g:Markdown()
exe "!".$HOME."/.vim/Markdown.pl --html4tags % > %.html"
" on Windows use default web browser. Elsewhere try chrome in
" incognito mode (no plugins). Feel free to change that to your
" favorite browser.
if has('win32')
exe "! %.html"
else
exe "! google-chrome --incognito %.html"
endif
endfunc
" bind this function to :M
command! M call g:Markdown()
" autocmd FileType html,htm,mkd,markdown nnoremap <leader>md :exe "%! ".$HOME."/.vim/Markdown.pl --html4tags"<cr>
endif
" use regular regex syntax rather than vim regex
nnoremap / /\v
vnoremap / /\v
"============= Command Aliases =============
" for when you mess up and hold shift too long (using ! to prevent errors while
" sourcing vimrc after it was updated)
command! W w
command! WQ wq
command! Wq wq
command! Q q
" changing file types:
command! DOS set ff=dos " force windows style line endings
command! UNIX set ff=unix " force unix style line endings
command! MAC set ff=mac " force mac style line endings
" This will display the path of the current file in the status line
" It will also copy the path to the unnamed register so it can be pasted
" with p or C-r C-r
command! FILEPATH call g:getFilePath()
function! g:getFilePath()
let @" = expand("%:p")
echom "Current file:" expand("%:p")
endfunc
"============= Buffers =============
set hidden " buffers can exist in background without being in a window
"============= Spell Check =============
set spell "enable in-line spell check
set spelllang=en
set nu " otherwise set absolute, because there is no rnu
set cul " highlight cursor line
set nopaste " pasting with auto-indent disabled (breaks bindings in cli vim)
" toggle between relative and absolute line numbers
function! g:ToggleNuMode()
if(&rnu == 1)
set nu
else
set rnu
endif
endfunc
" map the above function to F5
nnoremap <f5> :call g:ToggleNuMode()<cr>
"============= Scrolling & Position Tweaks =============
" show line and column markers
set cursorline
set scrolloff=3 " 3 line offset when scrolling
" turn off the *FUCKING* cursor blink
set guicursor=a:blinkon0
"============= Formatting, Indentation & Behavior =============
" enable soft word wrap
set formatoptions=l
set lbr
" use hard tabs for indentation
set tabstop=4
set softtabstop=4 " makes backspace treat 4 spaces like a tab
set shiftwidth=4 " makes indents 4 spaces wide as well
set expandtab " actually, expand tabs into spaces
"set noexpandtab " don't expand tabs to spaces (cause fuck that)
set backspace=indent,eol,start
au FocusLost * silent! :wa " save when switching focus
"============= Search & Matching =============
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " incremental search
set hlsearch " highlights searches
set noerrorbells " suppress audible bell
set novisualbell " suppress bell blink
"============= History =============
" save more in undo history
set history=1000
set undolevels=1000
if v:version >= 703
set undofile " keep a persistent backup file
set undodir=$TEMP
endif
"============= Misc =============
set autowrite " Automatically save before commands like :next and :make
set mouse=a " Enable mouse usage (all modes) in terminals
" sudo save file with w!
cmap w!! w !sudo tee % >/dev/null
" ============== Status Line ==============
set ls=2 " Always show status line
set laststatus=2
"============== Folding ==============
set nofoldenable " screw folding
"set foldmethod=indent
"set foldnestmax=3
"set foldenable
"============== Completion ==============
set wildmenu
set wildmode=list:longest
set wildignore=*.swp,*.bak,*.pyc,*.class,*.o,*.obj,*~
" longer more descriptive auto-complete prompts
set completeopt=longest,menuone
set ofu=syntaxcomplete#Complete
"============== Swap Files ==============
set noswapfile " suppress creation of swap files
set nobackup " suppress creation of backup files
set nowb " suppress creation of ~ files
"============== Misc ==============
" force txt files to be highlighted as html
au BufRead,BufNewFile *.txt setfiletype html
" force php files to be treated as php/html - necessary for snipmate to work
au BufRead,BufNewFile *.php set filetype=php.html
" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
"============== Pathogen ==============
call pathogen#infect()
"=========== Syntax Highlighting & Indents ==============
syntax on
filetype off
filetype on
filetype indent on
filetype plugin on
filetype plugin indent on
set autoindent " always indent
set copyindent " copy previous indent on autoindenting
set smartindent
set backspace=indent,eol,start " backspace over everything in insert mode
"============== Plugin Specific Settings ==============
" This is necessary to make Gdiff work
let g:miniBufExplorerMoreThanOne=3
" specific settings for terminal
set t_Co=256 " force vim to use 256 colors
" let g:solarized_termcolors=256 " use solarized 256 fallback
" set background=dark " change this if you want dark scheme
" Tell vim to change the shape of the cursor based on mode
" let &t_SI = "\<Esc>]50;CursorShape=1\x7"
" let &t_EI = "\<Esc>]50;CursorShape=0\x7"
" enable solarized color scheme
colorscheme Tomorrow-Night
" bind NERDTree to F1 (we don't need help)
nnoremap <f1> :NERDTreeToggle<cr>
" TagList shortcut
nnoremap <f2> :TlistToggle<cr>
nnoremap <C-t> :FufFile **/<cr>
" force snipmate accept custom defined snippets on windows
if has('win32')
let g:snippets_dir="c:/Users/luke/.vim/bundle/snipmate/snippets/,c:/Users/luke/.vim/bundle/snipmate-custom-snippets/snippets"
endif
" MiniBufExpl Plugin Settings
let g:miniBufExplMapCTabSwitchBufs = 1
" phpDocumentor shortcut
nnoremap <leader>d :call PhpDoc()<cr>
" key binding for the Gundo (undo preview) plugin
nnoremap <F7> :GundoToggle<CR>