.vimrc

changeset 665
807f6539d9cc
parent 658
69ed96c80ed0
child 666
0cf4a2458e49
equal deleted inserted replaced
664:66ba2d649859 665:807f6539d9cc
1 " vim: et sts=2 sw=2 1 " vim: et sts=2 sw=2
2 " vim: fdm=marker 2 " vim: fdm=marker
3 3
4 set nocompatible
5 set encoding=utf-8 4 set encoding=utf-8
6 scriptencoding utf-8 5 scriptencoding utf-8
7 6
8 " on windows and not cygwin 7 " on windows and not cygwin
9 let g:on_windows = (has('win32') || has('win64')) 8 let g:on_windows = (has('win32') || has('win64'))
62 61
63 call vundle#end() 62 call vundle#end()
64 " }}} 63 " }}}
65 64
66 " Key maps {{{ 65 " Key maps {{{
67 nmap <silent> <F1> :Unite buffer<CR> 66 nnoremap <silent> <F1> :Unite buffer<CR>
68 nmap <silent> <F2> :VimFilerExplorer<CR> 67 nnoremap <silent> <F2> :VimFilerExplorer<CR>
69 map <silent> <F4> :noh<CR> 68 noremap <silent> <F4> :noh<CR>
70 nmap <silent> <F5> :GundoToggle<CR> 69 nnoremap <silent> <F5> :GundoToggle<CR>
71 nmap <silent> <F8> :TagbarToggle<CR> 70 nnoremap <silent> <F8> :TagbarToggle<CR>
72 71
73 nmap <leader>uw :Unite -quick-match -short-source-names window tab:no-current<CR> 72 nnoremap <leader>uw :Unite -quick-match -short-source-names window tab:no-current<CR>
74 nmap <leader>us :Unite -quick-match session<CR> 73 nnoremap <leader>us :Unite -quick-match session<CR>
75 nmap <leader>uf :Unite -start-insert file_rec/async:!<CR> 74 nnoremap <leader>uf :Unite -start-insert file_rec/async:!<CR>
76 75
77 " stop opening help by mistake 76 " stop opening help by mistake
78 imap <F1> <ESC> 77 inoremap <F1> <ESC>
79 78
80 " let F4, :noh work as-is in insert mode 79 " let F4, :noh work as-is in insert mode
81 imap <F4> <C-O><F4> 80 imap <F4> <C-O><F4>
82 81
83 " chdir to the directory of the open buffer 82 " chdir to the directory of the open buffer
84 map <leader>cd :cd %:p:h<cr>:pwd<cr> 83 noremap <leader>cd :cd %:p:h<cr>:pwd<cr>
85 84
86 map <leader>pp :setlocal paste!<cr> 85 noremap <leader>pp :setlocal paste!<cr>
87 86
88 " faster window nav 87 " faster window nav
89 nmap <C-h> <C-w>h 88 nnoremap <C-h> <C-w>h
90 nmap <C-j> <C-w>j 89 nnoremap <C-j> <C-w>j
91 nmap <C-k> <C-w>k 90 nnoremap <C-k> <C-w>k
92 nmap <C-l> <C-w>l 91 nnoremap <C-l> <C-w>l
93 nmap <C-\> <C-w>p 92 nnoremap <C-\> <C-w>p
94 93
95 " navigate by on-screen lines 94 " navigate by on-screen lines
96 nnoremap <expr> j v:count ? 'j' : 'gj' 95 nnoremap <expr> j v:count ? 'j' : 'gj'
97 nnoremap <expr> k v:count ? 'k' : 'gk' 96 nnoremap <expr> k v:count ? 'k' : 'gk'
98 97
99 " alt buffer 98 " alt buffer
100 nmap gb <C-^> 99 nnoremap gb <C-^>
101 nmap gB :ls<CR>:b<Space> 100 nnoremap gB :ls<CR>:b<Space>
102 101
103 " Select last paste, in the same mode it was pasted in 102 " Select last paste, in the same mode it was pasted in
104 nmap <expr> gV '`[' . strpart(getregtype(), 0, 1) . '`]' 103 nnoremap <expr> gV '`[' . strpart(getregtype(), 0, 1) . '`]'
105 104
106 " Use ltag over tselect 105 " Use ltag over tselect
107 nmap g<C-]> :call vimrc#Ltag(expand('<cword>'))<CR> 106 nnoremap g<C-]> :call vimrc#Ltag(expand('<cword>'))<CR>
108 107
109 " clear all interestingwords with \\k since \K is ri.vim 108 " clear all interestingwords with \\k since \K is ri.vim
110 nmap <silent> <leader><leader>k :call UncolorAllWords()<CR> 109 nnoremap <silent> <leader><leader>k :call UncolorAllWords()<CR>
111 110
112 " use Ag for a recursive * 111 " use Ag for a recursive *
113 nmap g* :call ag#Ag('grep', '--literal ' . shellescape(expand("<cword>")))<CR> 112 nnoremap g* :call ag#Ag('grep', '--literal ' . shellescape(expand("<cword>")))<CR>
114 113
115 " K: doc, gK: Doc w/o using syntax hints, gKK: doc current filename 114 " K: doc, gK: Doc w/o using syntax hints, gKK: doc current filename
116 nmap K :call ViewDoc('doc', expand('<cword>'))<CR> 115 nnoremap K :call ViewDoc('doc', expand('<cword>'))<CR>
117 nmap gKK :call ViewDoc('doc', expand('%'))<CR> 116 nnoremap gKK :call ViewDoc('doc', expand('%'))<CR>
118 117
119 " Tabular shortcuts 118 " Tabular shortcuts
120 map <leader>ta :Tabularize first_arrow<CR> 119 noremap <leader>ta :Tabularize first_arrow<CR>
121 map <leader>te :Tabularize first_eq<CR> 120 noremap <leader>te :Tabularize first_eq<CR>
122 map <leader>tc :Tabularize first_colon<CR> 121 noremap <leader>tc :Tabularize first_colon<CR>
123 map <leader>tm :Tabularize methods<CR> 122 noremap <leader>tm :Tabularize methods<CR>
124 123
125 map <silent> <leader>a :call vimrc#AutoFmtToggle()<CR> 124 noremap <silent> <leader>a :call vimrc#AutoFmtToggle()<CR>
126 125
127 if exists("g:loaded_mucomplete") 126 if exists("g:loaded_mucomplete")
128 inoremap <expr> <c-e> mucomplete#popup_exit("\<c-e>") 127 inoremap <expr> <c-e> mucomplete#popup_exit("\<c-e>")
129 inoremap <expr> <c-y> mucomplete#popup_exit("\<c-y>") 128 inoremap <expr> <c-y> mucomplete#popup_exit("\<c-y>")
130 inoremap <expr> <cr> mucomplete#popup_exit("\<cr>") 129 inoremap <expr> <cr> mucomplete#popup_exit("\<cr>")
262 autocmd VimEnter * call vimrc#AutoSessionConfig() 261 autocmd VimEnter * call vimrc#AutoSessionConfig()
263 262
264 " complement to autowriteall 263 " complement to autowriteall
265 autocmd FocusLost * silent! wa 264 autocmd FocusLost * silent! wa
266 265
266 " Make paths when writing, as necessary
267 autocmd BufWritePre * :call vimrc#MkNonExDir(expand('<afile>'), +expand('<abuf>'))
268
267 " Jump to last known pos 269 " Jump to last known pos
268 autocmd BufReadPost * 270 autocmd BufReadPost *
269 \ if &filetype !~# 'mail\|^git\|^hg' && line("'\"") >= 1 && line("'\"") <= line("$") | 271 \ if &filetype !~# 'mail\|^git\|^hg' && line("'\"") >= 1 && line("'\"") <= line("$") |
270 \ exe "normal! g`\"" | 272 \ exe "normal! g`\"" |
271 \ endif 273 \ endif
283 285
284 autocmd BufReadPost quickfix nmap <buffer> q <C-w>c 286 autocmd BufReadPost quickfix nmap <buffer> q <C-w>c
285 287
286 " Neomutt changed their tmpfile pattern, ugh 288 " Neomutt changed their tmpfile pattern, ugh
287 autocmd BufNewFile,BufRead neomutt-*-\w\+ setf mail 289 autocmd BufNewFile,BufRead neomutt-*-\w\+ setf mail
288 augroup END
289
290 " Make paths when writing, as necessary
291 augroup AutoMkdir
292 autocmd!
293 autocmd BufWritePre * :call vimrc#MkNonExDir(expand('<afile>'), +expand('<abuf>'))
294 augroup END 290 augroup END
295 291
296 " https://mjj.io/2015/01/27/encrypting-files-with-gpg-and-vim/ 292 " https://mjj.io/2015/01/27/encrypting-files-with-gpg-and-vim/
297 " hacked to work with vimwiki 293 " hacked to work with vimwiki
298 augroup encrypted 294 augroup encrypted

mercurial