-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc
More file actions
193 lines (160 loc) · 4.52 KB
/
vimrc
File metadata and controls
193 lines (160 loc) · 4.52 KB
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
highlight Pmenu ctermbg=blue
highlight goTodo ctermbg=red
" normal backspace
set backspace=2
" syntax highlighting
syntax on
" indenting
filetype indent on
set autoindent
set smartindent
set background=dark
" abandon vi compat to enable extra features
set nocompatible
" enable filetype plugins
filetype plugin on
" ignore case on file autocomplete
set wildignorecase
" line ruler and ruler at bottom
set number
set ruler
" show auto complete menu
set wildmenu
" find recursive
set path+=**
" bash completion
set wildmode=list:longest
" highlight matching brackets
set showmatch
" open way more tabs
set tabpagemax=100
" search options
set ignorecase
set smartcase
set hlsearch " highlight results
set incsearch
set lazyredraw
" space and tabs
set expandtab
set smarttab
set shiftwidth=2
set softtabstop=2
set tabstop=4
autocmd BufNewFile,BufRead *.go set noexpandtab
autocmd BufNewFile,BufRead *.go set shiftwidth=4
autocmd BufNewFile,BufRead *.go set softtabstop=4
autocmd BufNewFile,BufRead *.go set tabstop=4
" linebreak at 500 chars
set lbr
set tw=80
set nowrap
" jump lines when wrapped
map j gj
map k gk
" map tabularize shortcuts
nmap <Leader>; vi{:'<,'>Tabularize/:\zs/l0l1<CR>
nmap <Leader>: vi(:'<,'>Tabularize/:\zs/l0l1<CR>
nmap <Leader>= :Tabularize/=<CR>
" nmap <Leader>w :Tabularize/\S\+\|`[^`]+`/l0l1<CR>
nmap <Leader>w vi{:'<,'>Tabularize/\S\+/l0l1<CR>
nmap <Leader>W vi(:'<,'>Tabularize/\S\+/l0l1<CR>
" write anywhere
set virtualedit=all
" keep selection after operation
vnoremap > ><CR>gv
vnoremap < <<CR>gv
" enable mouse support
set mouse=a
" more atomic writing for certain file watchers (webpack-dev-server)
set backupcopy=yes
" F3 lists buffers and selects one
nnoremap <F3> :ls<CR>:bu<Space>
" godef opens in new tab
let g:godef_split = 2
" session saving and loading
map <F2> :Sq<CR>
set ssop+=folds " save folds
command Sq call SaveAndQuit()
command S call Save()
function! Save()
:mksession! .session.vim
:wa
endfun
function! SaveAndQuit()
:mksession! .session.vim
:wqa
endfun
" Restore cursor position to where it was before
augroup JumpCursorOnEdit
au!
autocmd BufReadPost *
\ if expand("<afile>:p:h") !=? $TEMP |
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ let JumpCursorOnEdit_foo = line("'\"") |
\ let b:doopenfold = 1 |
\ if (foldlevel(JumpCursorOnEdit_foo) > foldlevel(JumpCursorOnEdit_foo - 1)) |
\ let JumpCursorOnEdit_foo = JumpCursorOnEdit_foo - 1 |
\ let b:doopenfold = 2 |
\ endif |
\ exe JumpCursorOnEdit_foo |
\ endif |
\ endif
" Need to postpone using "zv" until after reading the modelines.
autocmd BufWinEnter *
\ if exists("b:doopenfold") |
\ exe "normal zv" |
\ if(b:doopenfold > 1) |
\ exe "+".1 |
\ endif |
\ unlet b:doopenfold |
\ endif
augroup END
" Rename tabs to show tab number.
" (Based on http://stackoverflow.com/questions/5927952/whats-implementation-of-vims-default-tabline-function)
if exists("+showtabline")
function! MyTabLine()
let s = ''
let wn = ''
let t = tabpagenr()
let i = 1
while i <= tabpagenr('$')
let buflist = tabpagebuflist(i)
let winnr = tabpagewinnr(i)
let s .= '%' . i . 'T'
let s .= (i == t ? '%1*' : '%2*')
let s .= ' '
let wn = tabpagewinnr(i,'$')
let s .= '%#TabNum#'
let s .= i
" let s .= '%*'
let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#')
let bufnr = buflist[winnr - 1]
let file = bufname(bufnr)
let buftype = getbufvar(bufnr, 'buftype')
if buftype == 'nofile'
if file =~ '\/.'
let file = substitute(file, '.*\/\ze.', '', '')
endif
else
let file = fnamemodify(file, ':p:t')
endif
if file == ''
let file = '[No Name]'
endif
let s .= ' ' . file . ' '
let i = i + 1
endwhile
let s .= '%T%#TabLineFill#%='
let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X')
return s
endfunction
set stal=2
set tabline=%!MyTabLine()
set showtabline=1
highlight link TabNum Special
endif
" Use english for spellchecking, but don't spellcheck by default
if version >= 700
set spl=en spell
set nospell
endif