This repository has been archived by the owner on Jan 20, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
307 lines (228 loc) · 7.84 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
" Load vundle and plugins ============================================== {{{
set nocompatible " be iMproved
filetype off " required!
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle
" required!
Plugin 'VundleVim/Vundle.vim'
" My Bundles here:
"
" original repos on github
Plugin 'scrooloose/syntastic'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'klen/python-mode'
Plugin 'majutsushi/tagbar'
Plugin 'ehamberg/vim-cute-python'
call vundle#end() " required
filetype plugin indent on " required
"
" Brief help
" :BundleList - list configured bundles
" :BundleInstall(!) - install(update) bundles
" :BundleSearch(!) foo - search(or refresh cache first) for foo
" :BundleClean(!) - confirm(or auto-approve) removal of unused bundles
"
" see :h vundle for more details or wiki for FAQ
" NOTE: comments after Bundle command are not allowed..
" }}}
" VIM behaviour ========================================================== {{{
" Tell vim to remember certain things when we exit
" '10 : marks will be remembered for up to 10 previously edited files
" "100 : will save up to 100 lines for each register
" :20 : up to 20 lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
set viminfo='10,\"100,:20,%,n~/.vim/backup/.viminfo
" Show (partial) command in the last line of the screen.
set showcmd
" GUI settings
set title
" Don't update the display while executing macros
set lazyredraw
" Always display a status line at the bottom of the window
set laststatus=2
" Keep 3 lines visible down from the cursor while scrolling
set scrolloff=3
" Enable ctags support
set tags=./tags;/
" If file is not modified in VIM but changed outside, reload it
set autoread
" Keep commands history longer (by default keeps only 20 commands)
set history=1000
" Shows information on VIM bottom
set ruler
" Show line numbers in editor
set number
" Ignore case in search and replace
set ignorecase
" Found text will be highlighted and search will be repeated over file
set incsearch
" Smart search: if lowercase ignore case of matches, if not case-sensitive
set smartcase
" Keep VIM history even file is closed
set viminfo='20,<50,s10,h
" Remove trailing spaces after save
au BufWritePre * silent g/\s\+$/s///
" Set fold level to open all methods arround
set foldlevel=100
" }}}
" Edit behaviour ========================================================= {{{
" Encoding
set termencoding=utf-8
set encoding=utf-8
" Set tab to 4 spaces
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
" Enable wrap mode to see long code lines
set wrap
set textwidth=0
" Enable mouse features
set mouse=a
" For new lines automatically indent by current line indent
set autoindent
set copyindent
" Show matching for symbols like () and etc.
set showmatch
" Allow backspace on everything in insert mode
set backspace=indent,eol,start
" Word wrap not in the middle of the word
set formatoptions=l
set lbr
" }}}
" Edit behaviour based on fyle type ====================================== {{{
" HTML
autocmd Filetype html setlocal ts=2 sts=2 sw=2
" }}}
" Backups and swap ======================================================= {{{
set backup
set backupdir=~/.vim/backup
set noswapfile
" }}}
" Mappings =============================================================== {{{
" Mapleader from \ to ,
let mapleader=","
" <SHIFT + t> - trim white spaces in lines end
map <s-t> :%s/ \+$//g<CR>
" Toggles non printable character visibility
nmap <silent> <leader>w :set nolist!<CR>
" Allow to overwrite root protected files (in case of missed sudo)
cmap w!! %!sudo tee > /dev/null %
" Toggle NERDtree
map <leader>n :NERDTreeToggle<CR>
" TagBar Toggle
map <leader>m :TagbarToggle<CR>
" Spell Check
map <F5> <Esc>:setlocal spell spelllang=lt<CR>
map <F6> <Esc>:setlocal spell spelllang=en_us<CR>
map <F7> <Esc>:setlocal nospell<CR>
" No autoindent in paste mode
set pastetoggle=<F2>
" Clean search highlight on space
nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
" Simple Copy to system clipboard
vmap <C-c> y: call system("xclip -i -selection clipboard", getreg("\""))<CR>
" Simple paste in insert mode
imap <C-v> <Esc><C-v>a
" Insert new line above cursor
nmap <C-K> O<Esc>j
" Insert new line below cursor
nmap <C-J> o<Esc>k
" Insert space after cursor
nmap <C-L> li <Esc>h
" Insert space before cursor
nmap <C-H> i <Esc>l
" Insert new line after the cursor
nmap <CR> i<Enter><Esc>l
" Text wrap navigation made easy
map j gj
map k gk
" Reselect visual block after indent/outdent
vnoremap < <gv
vnoremap > >gv
" diff current vi buffer edits against original file
"nmap <leader>d :w !diff -u % -
" Easy window navigation/creation
map <leader>h :call WinMove('h')<cr>
map <leader>k :call WinMove('k')<cr>
map <leader>l :call WinMove('l')<cr>
map <leader>j :call WinMove('j')<cr>
" Move windows arround
map <leader>H :wincmd H<cr>
map <leader>K :wincmd K<cr>
map <leader>L :wincmd L<cr>
map <leader>J :wincmd J<cr>
" Resize windows with arrows
nmap <left> :3wincmd <<cr>
nmap <right> :3wincmd ><cr>
nmap <up> :3wincmd +<cr>
nmap <down> :3wincmd -<cr>
" Window close
map <leader>wc :wincmd q<cr>
" Window rotate
map <leader>wr <C-W>r
" Alias to ^w
nmap <C-q> <C-w>
" buffer search
map <leader>b :CtrlPBuffer<cr>
" }}}
" File types options ===================================================== {{{
" Ignore these file types on :e
set wildmenu
set wildmode=list:longest
set wildignore=*.swp,*.bak,*.pyc
" If VIM founds project.vim file in project root, it will be loaded.
" This is required if project has specific settings.
silent! source project.vim
" }}}
" Omnicomplete =========================================================== {{{
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
set completeopt=menuone,longest
" }}}
" Colors ================================================================= {{{
" Enable syntax highlighting
syntax on
" Set Color scheme
colorscheme molokai
" 256 colors
set t_Co=256
" Enable CursorLine
set cursorline
"" Paint 80 symbols line
set colorcolumn=80
hi colorcolumn ctermbg=234 cterm=none guibg=#293739
"" Omnicomplete colors
"highlight Pmenu
"\ cterm=NONE
"\ ctermbg=darkblue
"\ ctermfg=white
"\ guibg=darkblue
"\ guifg=white
" }}}
" Plugin Settings ======================================================== {{{
" NerdTree ----------------------------------------------------------- {{{
let NERDTreeMinimalUI=1
let NERDTreeDirArrows=1
let NERDTreeIgnore=['\.pyc$', '\.bak$', '\.swp$']
" }}}
" Custom functions ======================================================= {{{
function! WinMove(key)
" Helps moving arround windows
let t:curwin = winnr()
exec "wincmd ".a:key
if (t:curwin == winnr()) "we havent moved
if (match(a:key,'[jk]')) "were we going up/down
wincmd v
else
wincmd s
endif
exec "wincmd ".a:key
endif
endfunction
" }}}