-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
373 lines (293 loc) · 9.25 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
set encoding=utf-8
set nocompatible
filetype off
if has('vim_starting')
set nocompatible " Be iMproved
" Required:
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
" Required:
call neobundle#begin(expand('~/.vim/bundle/'))
" Let NeoBundle manage NeoBundle
NeoBundleFetch 'Shougo/neobundle.vim'
NeoBundle 'airblade/vim-gitgutter'
NeoBundle 'altercation/vim-colors-solarized'
NeoBundle 'bling/vim-airline'
NeoBundle 'Crapworks/python_fn.vim'
NeoBundle 'davidhalter/jedi-vim'
NeoBundle 'groenewege/vim-less'
NeoBundle 'honza/vim-snippets'
NeoBundle 'kchmck/vim-coffee-script'
NeoBundle 'kien/ctrlp.vim'
NeoBundle 'klen/python-mode'
NeoBundle 'Lokaltog/vim-easymotion'
" require: sudo apt-get install xdotool
NeoBundle 'lordm/vim-browser-reload-linux'
" require: sudo apt-get install exuberant-ctags
NeoBundle 'majutsushi/tagbar'
NeoBundle "mattn/emmet-vim"
" require: sudo apt-get install ack-grep
NeoBundle 'mileszs/ack.vim'
NeoBundle 'scrooloose/nerdcommenter'
NeoBundle 'scrooloose/nerdtree'
NeoBundle 'scrooloose/syntastic'
NeoBundle 'SirVer/ultisnips'
NeoBundle 'sjl/gundo.vim'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'tpope/vim-repeat'
NeoBundle 'tpope/vim-surround'
"Nekdy by bylo dobre zkusit: unite.vim
"NeoBundleLazy 'lambdalisue/vim-pyenv', {
"\ 'depends': ['davidhalter/jedi-vim'],
"\ 'autoload': {
"\ 'filetypes': ['python', 'python3'],
"\ }}
call neobundle#end()
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck
" Required:
filetype plugin indent on
syntax on
" theme
set t_Co=256
"set term=xterm-256color
"let g:solarized_termcolors=256
set background=dark
colorscheme solarized
highlight clear SignColumn
autocmd ColorScheme * highlight clear SignColumn
set cursorline
" Showing line numbers and length
set number " show line numbers
set tw=79 " width of document (used by gd)
set nowrap " don't automatically wrap on load
set fo-=t " don't automatically wrap text when typing
set colorcolumn=80
" gvim customizations
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r
set guifont=Ubuntu\ Mono\ 12
" Automatic reloading of .vimrc
"" autocmd! bufwritepost .vimrc source %
au BufWritePost .vimrc so ~/.vimrc
cmap w!! %!sudo tee > /dev/null %
" =============================================================================
" uncertainces
" =============================================================================
" Better copy & paste
" When you want to paste large blocks of code into vim, press F2 before you
" paste. At the bottom you should see ``-- INSERT (paste) --``.
set pastetoggle=<F2>
set clipboard=unnamed
" Mouse and backspace
set mouse=a " on OSX press ALT and click
set bs=2 " make backspace behave like normal again
"set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
"set directory=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
"==============================================================================
" Esc by press jk or kj
inoremap jk <Esc>
inoremap kj <Esc>
let mapleader = ","
nnoremap <leader>ev :tabedit $MYVIMRC<cr>
" @@ to repeat macro
map Q @@
" Bind nohl
" Removes highlight of your last search
" ``<C>`` stands for ``CTRL`` and therefore ``<C-n>`` stands for ``CTRL+n``
noremap <C-n> :nohl<CR>
vnoremap <C-n> :nohl<CR>
inoremap <C-n> :nohl<CR>
" Quick quit command
noremap <Leader>e :quit<CR> " Quit current window
noremap <Leader>E :qa!<CR> " Quit all windows
" easier moving of code blocks
" Try to go into visual mode (v), thenselect several lines of code here and
" then press ``>`` several times.
vnoremap < <gv " better indentation
vnoremap > >gv " better indentation
" easier formatting of paragraphs
"" vmap Q gq
"" nmap Q gqap
set history=1000
set undolevels=1000
" nice list
set listchars=tab:▸\ ,eol:¬,trail:⋅,extends:❯,precedes:❮
set showbreak=↪
set tabstop=4
set shiftwidth=4
"set softtabstop=4
"set shiftround
"set expandtab
au Filetype python setl et ts=4 sw=4
" Make search case insensitive
set hlsearch
set incsearch
set ignorecase
set smartcase
" Disable stupid backup and swap files - they trigger too many events
" for file system watchers
set nobackup
set nowritebackup
set noswapfile
:nmap <c-h> :tabprevious<cr>
:nmap <c-l> :tabnext<cr>
":nmap <C-S-tab> :tabprevious<cr>
":nmap <C-tab> :tabnext<cr>
":nmap <C-t> :tabnew<cr>
":map <C-t> :tabnew<cr>
":map <C-S-tab> :tabprevious<cr>
":map <C-tab> :tabnext<cr>
":map <C-w> :tabclose<cr>
":imap <C-S-tab> <ESC>:tabprevious<cr>i
":imap <C-tab> <ESC>:tabnext<cr>i
":imap <C-t> <ESC>:tabnew<cr>
" moving lines by holding alt
noremap <A-j> :m+<CR>
noremap <A-k> :m-2<CR>
inoremap <A-j> <Esc>:m+<CR>
inoremap <A-k> <Esc>:m-2<CR>
vnoremap <A-j> :m'>+<CR>gv
vnoremap <A-k> :m-2<CR>gv
" pro skakani na zacatek/konec radku v normal modu
noremap H ^
noremap L $
nmap t o<ESC>k
nmap T O<ESC>j
" =============================================================================
" Python IDE Setup
" =============================================================================
" python mode
let g:pymode_virtualenv = 1
let g:pymode_breakpoint = 1
let g:pymode_breakpoint_bind = '<leader>b'
"let g:pymode_breakpoint_cmd = 'ipdb'
let g:pymode_folding = 0
" disable ropes autocomplete for jedi
let g:pymode_rope_complete_on_dot = 0
let g:pymode_rope_completion = 0
let g:pymode_lint_cwindow = 0
let g:pymode_lint_write = 0
let g:pymode_lint = 0
" vim-jedi
"let g:jedi#auto_initialization = 0
let g:jedi#popup_select_first = 0
let g:jedi#use_tabs_not_buffers = 0
let g:jedi#show_call_signatures = 0 " buggy with history
map <leader>p :Pyimport
let g:jedi#usages_command="<leader>u"
" Ack
nmap <leader>a <Esc>:Ack!
" gundo
nnoremap <leader>h :GundoToggle<CR>
" ctrlp
let g:ctrlp_max_height = 30
set wildignore+=*.pyc
set wildignore+=*_build/*
set wildignore+=*/coverage/*
map <leader>t :CtrlPBufTag<CR>
" tagbar
let g:tagbar_usearrows = 1
nnoremap <leader>l :TagbarToggle<CR>
" nerdtree
map <Leader>n :NERDTreeToggle<CR>
let NERDTreeIgnore=['\.pyc$']
" vim-flake8 -- depends on flake8!
"autocmd BufWritePost *.py call Flake8()
" syntastic
"let g:syntastic_python_checkers=['flake8']
let g:syntastic_javascript_checkers = ['jshint']
" airline
set laststatus=2
let g:airline_left_sep=''
let g:airline_right_sep=''
" Short form mode text
let g:airline_mode_map = {
\ '__' : '-',
\ 'n' : 'N',
\ 'i' : 'I',
\ 'R' : 'R',
\ 'c' : 'C',
\ 'v' : 'V',
\ 'V' : 'V-L',
\ '' : 'V-B',
\ 's' : 'S',
\ 'S' : 'S-L',
\ '' : 'S-B',
\ }
"
" UltiSnips
let g:UltiSnipsRemoveSelectModeMappings = 1
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" Better navigating through omnicomplete option list
" See http://stackoverflow.com/questions/2170023/how-to-map-keys-for-popup-menu-in-vim
"set completeopt=longest,menuone
function! OmniPopup(action)
if pumvisible()
if a:action == 'j'
return "\<C-N>"
elseif a:action == 'k'
return "\<C-P>"
endif
endif
return a:action
endfunction
imap <silent><C-j> <C-R>=OmniPopup('j')<CR>
imap <silent><C-k> <C-R>=OmniPopup('k')<CR>
" =============================================================================
" utils
" =============================================================================
" Return indent (all whitespace at start of a line), converted from
" tabs to spaces if what = 1, or from spaces to tabs otherwise.
" When converting to tabs, result has no redundant spaces.
function! Indenting(indent, what, cols)
let spccol = repeat(' ', a:cols)
let result = substitute(a:indent, spccol, '\t', 'g')
let result = substitute(result, ' \+\ze\t', '', 'g')
if a:what == 1
let result = substitute(result, '\t', spccol, 'g')
endif
return result
endfunction
" Convert whitespace used for indenting (before first non-whitespace).
" what = 0 (convert spaces to tabs), or 1 (convert tabs to spaces).
" cols = string with number of columns per tab, or empty to use 'tabstop'.
" The cursor position is restored, but the cursor will be in a different
" column when the number of characters in the indent of the line is changed.
function! IndentConvert(line1, line2, what, cols)
let savepos = getpos('.')
let cols = empty(a:cols) ? &tabstop : a:cols
execute a:line1 . ',' . a:line2 . 's/^\s\+/\=Indenting(submatch(0), a:what, cols)/e'
call histdel('search', -1)
call setpos('.', savepos)
endfunction
command! -nargs=? -range=% Space2Tab call IndentConvert(<line1>,<line2>,0,<q-args>)
command! -nargs=? -range=% Tab2Space call IndentConvert(<line1>,<line2>,1,<q-args>)
command! -nargs=? -range=% RetabIndent call IndentConvert(<line1>,<line2>,&et,<q-args>)
" function for move tabs
function! ShiftTab(direction)
let tab_number = tabpagenr()
if a:direction == 0
if tab_number == 1
exe 'tabm' . tabpagenr('$')
else
exe 'tabm' . (tab_number - 2)
endif
else
if tab_number == tabpagenr('$')
exe 'tabm ' . 0
else
exe 'tabm ' . tab_number
endif
endif
return ''
endfunction
"inoremap <silent> <C-S-Left> <C-r>=ShiftTab(0)<CR>
"inoremap <silent> <C-S-Right> <C-r>=ShiftTab(1)<CR>
" shifting tabs
noremap <silent> <C-S-Left> :call ShiftTab(0)<CR>
noremap <silent> <C-S-Right> :call ShiftTab(1)<CR>
"==============================================================================