-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
238 lines (204 loc) · 6.77 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
" Compiled by Jonas Stenling from a number of sources on the interwebs.
"
" great pages about your .vimrc
" http://stevelosh.com/blog/2010/09/coming-home-to-vim/ -- google his vimrc
" http://naleid.com/blog/2010/10/04/vim-movement-shortcuts-wallpaper
" https://github.com/s3rvac/dotfiles/blob/master/vim/.vimrc -- crazy long
"
" use pathogen for plugin handling
execute pathogen#infect()
" disable vi compatibility
set nocompatible
" autocmds
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" set tabs for yaml
autocmd FileType yaml setlocal shiftwidth=2 tabstop=2
" automatic reloading of .vimrc
autocmd! bufwritepost vimrc source %
" enable switching between buffers with changes not written
set hidden
" various defaults from http://http://stevelosh.com/blog/2010/09/coming-home-to-vim/
set scrolloff=3
set showmode
set showcmd
set wildmenu
set wildmode=list:longest
set visualbell
set cursorline
set ttyfast
set noruler
set backspace=indent,eol,start
set relativenumber
set nobackup
set nowritebackup
set noswapfile
set history=700
set undolevels=700
" set 256 color mode
set t_Co=256
" Show whitespace
" MUST be inserted BEFORE the colorscheme command
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=23
au InsertLeave * match ExtraWhitespace /\s\+$/
colorscheme wombat256mod
" 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
" tab settings
set tabstop=4
set softtabstop=4
set shiftwidth=4
set shiftround
set expandtab
" indenting
set autoindent " Indent a new line according to the previous one.
set copyindent " Copy (exact) indention from the previous line.
set nopreserveindent " Do not try to preserve indention when indenting.
set nosmartindent " Turn off smartindent.
set nocindent " Turn off C-style indent.
" show tabs so tabs/spaces mixing is easy to spot
set list
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮
" comment handling
set fo+=q " Allow formatting of comments with "gq".
set fo-=r fo-=o " Turn off automatic insertion of comment characters.
set fo+=j " Remove a comment leader when joining comment lines.
" 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>
" Uncomment to automatically yank to system clipboard.
" I prefer to do it manually when needed with "+y
set clipboard=unnamedplus
" Make searching better
set ignorecase " case insensitive searching (unless specified)
set smartcase " use case sensitive search if there is capital letter
set incsearch " search incrementally as you type search string
set showmatch "
set hlsearch " highlight search matches
" splitting
set splitright "split to the right instead of left
set splitbelow "split below instead of above
" Mouse and backspace
set mouse=a " on OSX press ALT and click
" Enable syntax highlighting
" You need to reload this file for the change to apply
filetype off
filetype plugin indent on
syntax on
set colorcolumn=80
highlight ColorColumn ctermbg=233
" key mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" map K to help for current word
nnoremap K :help <C-r><C-w><CR>
" make D and Y to the same as C
nnoremap D d$
nnoremap Y y$
" Don't move on *
nnoremap <silent> * :let stay_star_view = winsaveview()<cr>*:call winrestview(stay_star_view)<cr>
" Keep search matches in the middle of the window.
nnoremap n nzzzv
nnoremap N Nzzzv
" Same when jumping around
nnoremap g; g;zz
nnoremap g, g,zz
nnoremap <c-o> <c-o>zz
" make window resizing easier
noremap <silent> < <C-W><
noremap <silent> > <C-W>>
noremap <silent> + <C-W>+
noremap <silent> - <C-W>-
" Rebind <Leader> key
let mapleader = ","
" leader macros
noremap <Leader>W :call <SID>StripTrailingWhiteSpaces()<CR>
vnoremap <Leader>s :sort<CR> " map sort function to a key
" Bind nohl
" Removes highlight of your last search
" ``<C>`` stands for ``CTRL`` and therefore ``<C-n>`` stands for ``CTRL+n``
noremap <silent> <Space> :nohl<CR>
" bind Ctrl+<movement> keys to move around the windows, instead of using Ctrl+w + <movement>
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
" unbind arrow keys for navigation
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" 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
" move between buffers
nnoremap <Leader>b :bp<CR>
nnoremap <Leader>f :bn<CR>
" close buffer but not window
nnoremap <Leader>c :bp\|bd #<CR>
" functions
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" this function will restore search history and cursor position when removing
" trailing whitespace with <Leader>W
function! <SID>StripTrailingWhiteSpaces()
let _s=@/
let l = line(".")
let c = col(".")
" do the business
%s/\s\+$//e
" restore previous search history and cursor position
let @/=_s
call cursor(l,c)
endfunction
" plugin settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" syntastic settings
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_python_flake8_args='--max-line-length=100'
" settings for Nerdtree
map <C-n> :NERDTreeToggle<CR>
let g:NERDTreeWinPos = "right" " move nerdtree to the right
" vim-airline settings
let g:airline#extensions#tabline#enabled = 1
set laststatus=2
let g:airline_theme='powerlineish'
let g:airline_left_sep=''
let g:airline_right_sep=''
"let g:airline_section_z=''
let g:airline_powerline_fonts = 1
" Settings for jedi-vim
let g:jedi#popup_on_dot = 1
let g:jedi#popup_select_first = 1
let g:jedi#use_splits_not_buffers = "right"
" 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
inoremap <silent><C-j> <C-R>=OmniPopup('j')<CR>
inoremap <silent><C-k> <C-R>=OmniPopup('k')<CR>