-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc.after
170 lines (143 loc) · 4.53 KB
/
vimrc.after
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
"nnoremap <C-J> <C-W><C-J>
"nnoremap <C-K> <C-W><C-K>
"nnoremap <C-L> <C-W><C-L>
"nnoremap <C-H> <C-W><C-H>
tnoremap <ESC> <C-\><C-n>
tnoremap <A-j> <C-\><C-n><C-w>j
tnoremap <A-k> <C-\><C-n><C-w>k
tnoremap <A-l> <C-\><C-n><C-w>l
tnoremap <A-h> <C-\><C-n><C-w>h
" set cursorline
"set background=dark
"let g:solarized_termcolors = 256
"let g:solarized_visibility = "high"
"let g:solarized_contrast = "high"
"let g:solarized_termtrans=1
colorscheme molokai
"set cursorline
highlight CursorLine ctermbg=17
set cc=80
highlight ColorColumn ctermbg=0 guibg=darkgrey
set rnu
" Try to speed up cursor movement
set lazyredraw
set ttyfast
"cpp-enhanced-highlight option
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1
let g:cpp_experimental_template_highlight = 1
" clang-format
autocmd FileType c,cpp,cc map <C-Y> :pyf ~/install/scripts/clang-format.py<cr>
autocmd FileType c,cpp,cc imap <C-Y> <c-o>:pyf ~/install/scripts/clang-format.py<cr>
autocmd FileType python map <C-Y> :call yapf#YAPF()<cr>
autocmd FileType python imap <C-Y> <c-o>:call yapf#YAPF()<cr>
" speed up ESC key
set timeoutlen=1000 ttimeoutlen=0
" CtrlP
let g:ctrlp_working_path_mode = 'raw'
function! SwitchBufferEnter()
if &buftype ==# 'quickfix'
execute "normal! \<CR>"
else
:CtrlPBuffer
endif
endfunction
nnoremap <CR> :call SwitchBufferEnter()<CR>
"nnoremap <CR> :CtrlPBuffer<CR>
"----------
" ctrlp.vim
"----------
let g:ctrlp_cache_dir = $HOME . '/.cache/ctrlp'
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_follow_symlinks = 1
let g:ctrlp_working_path_mode = 'rw'
" Ignore some folders and files for CtrlP indexing
" Note: this won't work because we use ag for ctrlp_user_command. Ignore patterns should be
" handled by ag as below.
"set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.idea/*,*/build/*,*/.DS_Store,*/vendor
" Launch CtrlP. Use this and then start typing fragments of the file path.
nnoremap <leader>ff :CtrlP<cr>
" auto reload file
" check one time after 4s of inactivity in normal mode
set autoread
au CursorHold * checktime
" use ag instead of Ack
if executable('ag')
let g:ackprg = 'ag --vimgrep'
let g:ctrlp_user_command = 'ag %s -i -l -f --nocolor --nogroup -g ""'
"let g:ctrlp_use_caching = 0
" this matcher speeds up ctrlp matching significantly for large projects
let g:ctrlp_max_files = 0
"let g:ctrlp_match_func = {'match' : 'matcher#cmatch' }
endif
" Alt-F to grep
nnoremap ƒ :Ack<SPACE>
" Shift-K to grep word under cursor
nnoremap K :Ack! "\b<C-R><C-W>\b"<CR>:cw<CR>
" Copy and paste to system clipboard
vmap <Leader>y "+y
vmap <Leader>d "+d
nmap <Leader>p "+p
nmap <Leader>P "+P
vmap <Leader>p "+p
vmap <Leader>P "+P
set pastetoggle=<F2> "http://nvie.com/posts/how-i-boosted-my-vim/"
set nobackup
set noswapfile
set clipboard=unnamed
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
" Alt-j/k to move lines up/down
nnoremap ∆ :m .+1<CR>==
nnoremap ˚ :m .-2<CR>==
inoremap ∆ <Esc>:m .+1<CR>==gi
inoremap ˚ <Esc>:m .-2<CR>==gi
vnoremap ∆ :m '>+1<CR>gv=gv
vnoremap ˚ :m '<-2<CR>gv=gv
" Code folding
set foldmethod=syntax
set foldnestmax=10
set nofoldenable
set foldlevel=10
let c_no_comment_fold = 1
" Close buffer without closing window
" http://stackoverflow.com/a/8585343
map <leader>q :silent! bp<bar>sp<bar>bn<bar>bd<CR>
" ctags
" look in the current directory for tags and work up the tree towards root
" until one is found (can be anywhere in the source tree)
set tags=./tags;/
" C\ open the definition in a new tab
map <C-\> :tab split<CR>:exec("tag ".expand("<cword>"))<CR>
" A] open the definition in a vertical split
map <A-]> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
nnoremap <leader>. :CtrlPTag<cr>
" scons files
au BufNewFile,BufRead SCons* set filetype=scons
" Delete buffer in CtrlP
let g:ctrlp_buffer_func = { 'enter': 'MyCtrlPMappings' }
func! MyCtrlPMappings()
nnoremap <buffer> <silent> <c-@> :call <sid>DeleteBuffer()<cr>
endfunc
func! s:DeleteBuffer()
let line = getline('.')
let bufid = line =~ '\[\d\+\*No Name\]$' ? str2nr(matchstr(line, '\d\+'))
\ : fnamemodify(line[2:], ':p')
exec "bd" bufid
exec "norm \<F5>"
endfunc
" Wrap lines vimcasts.org/episodes/soft-wrapping-text
command! -nargs=* Wrap set wrap linebreak nolist
" Tab navigation
map <D-]> gt
map <D-[> gT
hi MatchParen cterm=underline ctermbg=none ctermfg=none
let s:maxoff = 50 " maximum number of lines to look backwards.
let pyindent_nested_paren="&sw*2"
let pyindent_open_paren="&sw*2"
"GitGutter Sign column always on
if exists('&signcolumn') " Vim 7.4.2201
set signcolumn=yes
else
let g:gitgutter_sign_column_always = 1
endif