-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
255 lines (195 loc) · 6.6 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
" Automatic reloading of .vimrc
autocmd! bufwritepost .vimrc source %
" 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
" Disable compatibility mode for vi
set nocompatible
" Don't show insert bellow powerlinie
set noshowmode
set laststatus=2
"if &term =~ '256color'
"" Disable Background Color Erase so that color schemes
"" work properly when Vim is used isnide tmux and GNU screen.
"set t_ut=
"endif
" Show whitespace
" MUST be inserted BEFORE the colorscheme command
autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red
au InsertLeave * match ExtraWhitespace /\s\+$/
" Enable syntax highlighting
" You need to reload this file for the change to apply
filetype off
filetype plugin indent on
syntax enable
set background=light
"let g:solarized_termcolors=256
colorscheme gotham
" By default use relative numbers
set relativenumber
" Enable toggle between relative numbers
function! NumberToggle()
if(&relativenumber == 1)
set norelativenumber
else
set relativenumber
endif
endfunc
nnoremap <space> : call NumberToggle()<cr>
" Automatically toggle numbers when entering/leaving insert mode
autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set relativenumber
" Autocomplete with Tab and the words file from linux
function! Tab_Or_Compete()
if col('.')>1 && strpart( getline('.'), col('.')-2, 3) =~ '^\w'
return "\<C-N>"
else
return "\<Tab>"
endif
endfunction
inoremap <Tab> <C-R>=Tab_Or_Compete()<CR>
set dictionary+=/usr/share/dict/words
set complete+=k
set complete+=]
set ignorecase
set infercase
" Mouse and backspace
"" set mouse=a " on OSX press ALT and click
"" set bs=2 " make backspace behave like normal again
" Rebind <Leader> key
" I like to have it here becuase it is easier to reach than the default and
" it is next to ``m`` and ``n`` which I use for navigating between buffers.
let mapleader = ","
" remap ESC to ii
imap ii <ESC>
" 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>
" Quicksave command
noremap <C-Z> :update<CR>
vnoremap <C-Z> <C-C>:update<CR>
inoremap <C-Z> <C-O>:update<CR>
noremap <leader>s :update<CR>
" Quick quit command
noremap <Leader>e :<esc>:bd<CR> " Delete current buffer
noremap <Leader>E :qa!<CR> " Quit all windows
" bind Ctrl+<movement> keys to move around the windows, instead of using Ctrl+w + <movement>
" Every unnecessary keystroke that can be saved is good for your health :)
map <c-j> <c-w>j
map <c-k> <c-w>k
map <c-l> <c-w>l
map <c-h> <c-w>h
" easier moving between buffers
map <Leader>n <esc>:bp<CR>
map <Leader>m <esc>:bn<CR>
" delete into black hole
nnoremap <leader>d "_d
" map sort function to a key
"" vnoremap <Leader>s :sort<CR>
" 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
" move between lines with same indention
nnoremap <Leader>k :call search('^'. matchstr(getline('.'), '\(^\s*\)') .'\%<' . line('.') . 'l\S', 'be')<CR>
nnoremap <Leader>j :call search('^'. matchstr(getline('.'), '\(^\s*\)') .'\%>' . line('.') . 'l\S', 'e')<CR>
" Color scheme
" mkdir -p ~/.vim/colors && cd ~/.vim/colors
" wget -O wombat256mod.vim http://www.vim.org/scripts/download_script.php?src_id=13400
"set t_Co=256
"color 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
"set colorcolumn=80
"highlight ColorColumn ctermbg=233
" easier formatting of paragraphs
"" vmap Q gq
"" nmap Q gqap
" Useful settings
set history=700
set undolevels=700
" Real programmers don't use TABs but spaces
set tabstop=4
set softtabstop=4
set shiftwidth=4
set shiftround
set expandtab
" 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
" Setup Pathogen to manage your plugins
" mkdir -p ~/.vim/autoload ~/.vim/bundle
" curl -so ~/.vim/autoload/pathogen.vim https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim
" Now you can install any plugin into a .vim/bundle/plugin-name/ folder
call pathogen#infect()
" ============================================================================
" Python IDE Setup
" ============================================================================
" Settings for ack searcher
" cd ~/.vim/bundle
" git clone git:/mileszs/ack.vim.git
" check if silver searcher (ag) is installed, if so, use it instad of ack
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
cnoreabbrev Ack Ack!
nnoremap <Leader>a :Ack!<Space>
" Settings for vim-powerline
" cd ~/.vim/bundle
" git clone git:/Lokaltog/vim-powerline.git
set laststatus=2
" Settings for ctrlp
" cd ~/.vim/bundle
" git clone https:/kien/ctrlp.vim.git
let g:ctrlp_max_height = 30
set wildignore+=*.pyc
set wildignore+=*_build/*
set wildignore+=*/coverage/*
" Settings for jedi-vim
" cd ~/.vim/bundle
" git clone git:/davidhalter/jedi-vim.git
let g:jedi#usages_command = "<leader>z"
let g:jedi#popup_on_dot = 0
let g:jedi#popup_select_first = 0
let g:jedi#use_splits_not_buffers = "right"
map <Leader>b Oimport ipdb; ipdb.set_trace() # BREAKPOINT<C-c>
" 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>
" pip8 check everytime file is saves
autocmd BufWritePost *.py call Flake8()
" jsx highlighting in js files
let g:jsx_pragma_required = 0
" Python folding
" mkdir -p ~/.vim/ftplugin
" wget -O ~/.vim/ftplugin/python_editing.vim http://www.vim.org/scripts/download_script.php?src_id=5492
set nofoldenable
vmap <Leader>b :<C-U>!hg blame -fu <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR> " hg blame