Created
November 15, 2013 17:13
-
-
Save humus/7488008 to your computer and use it in GitHub Desktop.
mi _vimrc en windows
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set enc=utf-8 | |
| set nocompatible | |
| set et | |
| set sw=4 | |
| set sts=4 | |
| set ts=4 | |
| set noswapfile | |
| syntax on | |
| set ignorecase | |
| set smartcase | |
| set autoindent | |
| set smartindent | |
| nnoremap Y y$ | |
| set guifont=DejaVu_Sans_Mono_for_Powerline:h10:cANSI | |
| set guioptions-=m | |
| set guioptions-=T | |
| set guioptions-=r | |
| set guioptions-=L | |
| set ff=unix | |
| let g:ruby_path = 'C:\RailsInstaller\Ruby1.9.3\bin' | |
| imap <C-s> <C-o>:w<CR> | |
| nmap <C-s> :w<CR> | |
| imap <C-F5> <C-o>:so $MYVIMRC<CR> | |
| nmap <C-F5> :so $MYVIMRC<CR> | |
| imap <A-j> <C-o>:bn<CR> | |
| nmap <A-j> :bn<CR> | |
| imap <A-k> <C-o>:bp<CR> | |
| nmap <A-k> :bp<CR> | |
| nmap <A-l> :tabnext<CR> | |
| nmap <A-h> :tabprevious<CR> | |
| "Pathogen FTW | |
| filetype off | |
| runtime bundle/pathogen/autoload/pathogen.vim | |
| call pathogen#infect() | |
| let g:xptemplate_snippet_folders=['$VIMRUNTIME/../vimfiles/bundle/xptemplate/personal_snippets'] | |
| set nowrap | |
| colo blackboard | |
| au BufRead * setl autoread | |
| "After pathogen configuration | |
| filetype indent plugin on | |
| "leader mappings | |
| let mapleader="," | |
| let maplocalleader="," | |
| imap <silent><leader>t <><Left> | |
| cnoremap <silent><leader>t <><Left> | |
| inoremap <silent><C-f> <Right> | |
| inoremap <silent><C-b> <Left> | |
| inoremap <leader>r []<Left> | |
| inoremap <leader>c ()<Left> | |
| inoremap <leader>x {}<Left> | |
| inoremap <leader><leader>x {<CR>}<Up><End><CR> | |
| noremap <leader>b \ | |
| nmap <leader>b \ | |
| noremap! <leader>b \ | |
| inoremap <leader>a ''<Left> | |
| inoremap <leader>q ""<Left> | |
| inoremap <leader>e =""<Left> | |
| inoremap <leader>s * | |
| inoremap <leader>. <C-o>:s/\s*;\?$/;<CR><End> | |
| inoremap <leader>z ` | |
| "listchars | |
| set list | |
| set listchars =tab:»\ ,eol:¬,trail:· | |
| set hidden | |
| map! <A--> / | |
| nmap <A--> / | |
| map! <A-6> ^ | |
| nmap <A-6> ^ | |
| map! <A-}> ` | |
| map <leader>6 ^ | |
| map! <leader>6 ^ | |
| inoremap <Leader>f > | |
| inoremap <Leader>g < | |
| inoremap <Leader>F >> | |
| inoremap <Leader>G << | |
| inoremap <leader>k : | |
| nnoremap <leader>k :<C-f>i | |
| inoremap <leader>7 / | |
| nnoremap <leader>7 / | |
| cnoremap <leader>7 / | |
| nnoremap <Leader>2 / | |
| inoremap <Leader>2 / | |
| cnoremap <Leader>2 / | |
| au filetype vim imap <buffer> <leader>w ``<left> | |
| au filetype sh imap <buffer> <leader>w ``<left> | |
| au filetype vim imap <buffer> <leader>} ` | |
| au filetype sh imap <buffer> <leader>} ` | |
| vmap { <gv | |
| vmap } >gv | |
| "Persistent undo | |
| set undofile | |
| set undodir=C:\tmp | |
| "leader options | |
| nmap <leader>t :NERDTreeToggle<CR> | |
| nmap <leader>h :set hls!<CR> | |
| au FileType yaml setl sts=2 ts=2 sw=2 et | |
| au FileType plantuml setl sts=2 ts=2 sw=2 et | |
| au FileType python nmap <leader><leader>x :exec "!python " . expand('%:p') <CR> | |
| au FileType tex setl tw=80 | |
| "au FileType tex nmap <C-2> :exe 'Clam pdflatex ' . expand('%')<CR> | |
| au BufRead,BufNewFile *.qtask setf quicktask | |
| au BufRead,BufNewFile *.quicktask setf quicktask | |
| au FileType quicktask setlocal ts=2 sts=2 sw=2 nospell | |
| au FileType jsp setlocal ft=html.jsp | |
| nmap <F8> :call Swap_ts_sw_sts()<CR> | |
| fun! Swap_ts_sw_sts() "{{{ | |
| let l:curr_setting = &ts | |
| let l:new_setting = '4' | |
| if (l:curr_setting == '4') | |
| let l:new_setting = '2' | |
| endif | |
| let l:opts = join([ | |
| \ ":set ts=", l:new_setting, " " | |
| \ , "sw=", l:new_setting, " " | |
| \ , "sts=", l:new_setting], "") | |
| exe l:opts | |
| endfunction "}}} | |
| set ls=2 | |
| nmap BW :BW<CR> | |
| nmap BD :BD<CR> | |
| " | |
| " Snippet triggering key: | |
| let g:xptemplate_key = '<Leader><Tab>' | |
| " | |
| " Open the pop-up menu: | |
| let g:xptemplate_key_pum_only = '<S-Tab>' | |
| " | |
| " Clear current placeholder and jump to the next: | |
| "imap <C-d> <Tab> | |
| "let g:xptemplate_nav_cancel = '<C-d>' | |
| " | |
| " Move to the next placeholder in a snippet: | |
| let g:xptemplate_nav_next = '<Tab>' | |
| " | |
| " Go to the end of the current placeholder and in to insert mode: | |
| " | |
| " | |
| " Move cursor back to last placeholder: | |
| "let g:xptemplate_goback = '<C-g>' | |
| " | |
| "Emmet | |
| let g:user_emmet_leader_key = '<C-Space>' | |
| nmap <Leader>1 :NERDTreeFind<CR> | |
| nnoremap <F1> :MarksBrowser<CR> | |
| nmap <F3> :CtrlPMRUFiles<CR> | |
| if getcwd() == $USERPROFILE | |
| cd C:\home\r\ | |
| endif | |
| setg nospell | |
| nmap <Space> : | |
| nmap <S-Space> /\v | |
| set tags=./tags;/ | |
| imap <Leader>" @ | |
| imap <Leader>Q @ | |
| nmap <F9> :! start /min attrib -R %<CR> | |
| let g:ConqueTerm_EscKey = '<C-l>' | |
| fun! s:Alternate() "{{{ | |
| let file_path = expand('%:p:h') | |
| if file_path =~ '.*\<test\>' | |
| call s:SwitchFromTest() | |
| return | |
| endif | |
| call s:SwitchToTest() | |
| endfunction "}}} | |
| fun! s:SwitchFromTest() "{{{ | |
| let package_loc = search("^package", 'bn') | |
| if package_loc == 0 | |
| echohl WarningMsg | echo 'NULL' | echohl None | |
| return | |
| endif | |
| let package = getline(package_loc) | |
| let file_path = expand('%:p:h') | |
| let path_prefix = substitute(file_path, '\W\zstest\ze\W', 'main', '') | |
| let test_name = expand('%:t:r') | |
| let full_path_one = path_prefix . '/' . substitute(test_name, 'Test', '', '') . '.java' | |
| let full_path_two = path_prefix . '/impl/' . substitute(test_name, 'Test', '', '') . 'Impl.java' | |
| let full_path_three = path_prefix . '/' . substitute(test_name, 'Test', '', '') . 'Impl.java' | |
| let paths = [full_path_one, full_path_two, full_path_three] | |
| if !filereadable(full_path_one) && !filereadable(full_path_two) && !filereadable(full_path_three) | |
| try | |
| call CreateFileToTest(paths, package) | |
| catch /CANCEL/ | |
| echohl WarningMsg | echo "CANCEL" | echohl None | |
| return | |
| endtry | |
| endif | |
| for full_path in paths | |
| if filereadable(full_path) && filewritable(full_path) | |
| let file_to_test = full_path | |
| break | |
| endif | |
| endfor | |
| exe 'e ' . file_to_test | |
| endfunction "}}} | |
| fun! CreateFileToTest(paths, package) "{{{ | |
| let message = '' | |
| for path_ in a:paths | |
| let message .= path_ . "\n" | |
| endfor | |
| echo a:paths | |
| let message .= 'None, Cancel' | |
| let choice = confirm('File will be?', message, 1) | |
| if choice == 0 || choice == len(a:paths) + 1 | |
| throw "CANCEL" | |
| endif | |
| let path = a:paths[choice-1] | |
| let a_dir = join(split(path, '[\\/]')[:-2], '/') | |
| if !isdirectory(a_dir) | |
| call mkdir(a_dir, 'p') | |
| endif | |
| let package = a:package | |
| if a_dir =~ 'impl\W' | |
| let package .= '.impl' | |
| endif | |
| let class_name = split(split(path, '[\\/]')[-1], '\.')[0] | |
| call writefile([package | |
| \ , '', 'public class ' . class_name | |
| \ . '/*implements ' . substitute(class_name, 'Impl', '', ''), '*/ {' | |
| \ , '', '}', ''], path) | |
| endfunction "}}} | |
| fun! s:SwitchToTest() "{{{ | |
| let package_loc = search("^package", 'bn') | |
| if package_loc == 0 | |
| echohl WarningMsg | echo 'NULL' | echohl None | |
| return | |
| endif | |
| let package = getline(package_loc) | |
| let file_path = expand('%:p:h') | |
| " teniendo: ${basedir}/src/main/my/package/name | |
| " new_file_path queda como ${basedir}/src/test/my/package/name | |
| " teniendo ${basedir}/src/main/my/package/name/impl | |
| " new_file_path queda como ${basedir}/src/test/my/package/name | |
| let new_file_path = substitute(substitute(file_path, '\W\zsmain\ze\W', 'test', ''), '\W\zsimpl\(\W\|$\)', '', '') | |
| if !isdirectory(new_file_path) | |
| call mkdir(new_file_path, 'p') | |
| endif | |
| let test_name = substitute(expand('%:t:r'), '\(Impl\|Test\)$', '', '') . 'Test.java' | |
| let test_file = new_file_path . '/' . test_name | |
| if !filewritable(test_file) && !filereadable(test_file) | |
| call writefile([package, '', 'public class ' . split(test_name, '\.')[0] . ' {', '' , '}'], test_file) | |
| endif | |
| execute 'e ' . test_file | |
| endfunction "}}} | |
| fun! s:UnitTest() "{{{ | |
| let test_name = expand('%:t:r') . 'Test' | |
| let test_name = substitute(test_name, 'TestTest', 'Test', '') | |
| let pom_file = findfile('pom.xml', '.;') | |
| execute ':Dispatch mvn -f ' . pom_file . ' -q test -Dtest=' . test_name | |
| endfunction "}}} | |
| fun! s:tex_deleteaux_and_log() "{{{ | |
| let aux_file_name = expand('%:r') . '.aux' | |
| let log_file_name = expand('%:r') . '.log' | |
| call system('rm ' . aux_file_name . ' ' . log_file_name) | |
| echohl WarningMsg | echo "DONE" | echohl None | |
| endfunction "}}} | |
| fun! s:ImportCurrent() "{{{ | |
| let _cursor = getpos('.') | |
| let package = getline(searchpos("^package", 'b')[0]) | |
| let import_result = substitute(package, '^package\s\+', '', '') | |
| let import_result = substitute(import_result, ';', '', '') . '.' . expand('%:t:r') | |
| let import_result = 'import ' . import_result . ';' | |
| let @+ = import_result | |
| let @* = import_result | |
| call setpos('.', _cursor) | |
| endfunction "}}} | |
| fun! s:FindImport() "{{{ | |
| let a_class = expand("<cword>") | |
| let expression = '^import .\+\<' . a_class . ';$' | |
| let _pos = searchpos(expression, 'bn')[0] | |
| if _pos == 0 | |
| echohl ErrorMsg | echo a_class | echohl None | |
| return | |
| endif | |
| let _import = getline(_pos) | |
| let @+ = _import | |
| let @* = _import | |
| endfunction "}}} | |
| fun! s:Paste_Import() "{{{ | |
| let curpos = getpos('.') | |
| normal H | |
| let firstrow = getpos('.') | |
| call setpos('.', [0, 1, 1, 0]) | |
| let apos = searchpos('import \S\+;', 'W') | |
| while apos[0] != 0 | |
| let apos = searchpos('import \S\+;', 'W') | |
| endwhile | |
| execute 'normal o+' | |
| let curpos[1] = curpos[1] + 1 | |
| let firstrow[1] = firstrow[1] + 1 | |
| call setpos('.', firstrow) | |
| normal zt | |
| call setpos('.', curpos) | |
| endfunction "}}} | |
| fun! s:Snake_case() "{{{ | |
| let clazz_name = expand('%:t:r') | |
| let snake_cased = substitute(clazz_name, '\C\([a-z]\)\@<=[A-Z]\+', '_&', 'g') | |
| call feedkeys('a' . snake_cased . "\<Esc>") | |
| endfunction "}}} | |
| fun! s:Uppercase_last_i() "{{{ | |
| silent normal `[ | |
| silent normal gU`] | |
| silent normal `] | |
| silent normal gUee | |
| endfunction "}}} | |
| fun! s:Snake_case_last_i() "{{{ | |
| let old_z = @z | |
| execute 'normal `["zy`]' | |
| execute 'normal `["_d`]' | |
| let @z = substitute(@z, '\s*\S\+\zs\s\ze\S', '_', 'g') | |
| call feedkeys('i' . @z . "\<Esc>") | |
| let @z = old_z | |
| endfunction "}}} | |
| fun! s:Ant(ant_target) "{{{ | |
| let base = expand('%:p:h') | |
| let build_file = findfile('build.xml', '.;/;' . base) | |
| if build_file != '' | |
| execute 'Dispatch ant -v -f ' .build_file . ' ' . ant_target | |
| else | |
| echohl WarningMsg | echo 'nofile' | echohl None | |
| endif | |
| endfunction "}}} | |
| fun! s:Config_ant() "{{{ | |
| call s:Reconfig_ant('compile') | |
| endfunction "}}} | |
| fun! s:Reconfig_ant(anttarget) "{{{ | |
| let build_file = findfile('build.xml', expand('%:p:h') . '.;') | |
| if build_file != '' | |
| execute 'setl makeprg=ant\ -f\ ' . build_file . '\ ' . anttarget | |
| endif | |
| endfunction "}}} | |
| fun! Camel_last() "{{{ | |
| let start_mod = getpos("'[") | |
| let end_mod = getpos("']") | |
| if (start_mod[1] != end_mod[1]) | |
| return | |
| endif | |
| let mod_line = getline(start_mod[1]) | |
| let inserted_text = mod_line[start_mod[2] - 1 :end_mod[2] - 2] | |
| let text_replacement = substitute(inserted_text, '\v%(\S)@<=\s(\w)', '\u\1', 'g') | |
| let prepared_line = '' | |
| if start_mod[2] > 1 | |
| let prepared_line .= mod_line[0:start_mod[2] - 2] | |
| endif | |
| let prepared_line .= mod_line[end_mod[2] - 1:-1] | |
| call setline(start_mod[1], prepared_line) | |
| call setpos('.', start_mod) | |
| let @z = text_replacement | |
| let @x = inserted_text | |
| call feedkeys('i' . text_replacement . "\<Esc>") | |
| endfunction "}}} | |
| command! CamelCaseLast call Camel_last() | |
| cab lcc CamelCaseLast | |
| au FileType java command! T call s:SwitchToTest() | |
| au FileType java command! UT call s:UnitTest() | |
| au FileType java cabbrev ut UT | |
| au FileType java iabbrev pv private ; | |
| au FileType java command! IC call s:ImportCurrent() | |
| au FileType java cabbrev ic IC | |
| au FileType java command! FI call s:FindImport() | |
| au FileType java cabbrev fi FI | |
| au FileType java cabbrev a A | |
| au FileType java command! A call s:Alternate() | |
| au FileType java command! SC call s:Snake_case() | |
| au FileType java command! PI call s:Paste_Import() | |
| au BufNewFile,BufRead *.groovy setf groovy | |
| au BufNewFile *.tex setf tex | |
| au FileType tex command! D call s:tex_deleteaux_and_log() | |
| au FileType tex cabbrev d D | |
| command! UL call s:Uppercase_last_i() | |
| command! SL call s:Snake_case_last_i() | |
| command! ANT call s:Ant() | |
| command! -nargs=+ Rant call s:Rant(<q-args>) | |
| cabbrev rant Rant | |
| cabbrev ntb NERDTreeFromBookmark | |
| cabbrev sc SC | |
| cabbrev gul UL | |
| cabbrev sl SL | |
| cabbrev pi PI | |
| cabbrev an ANT | |
| cabbrev ant ANT | |
| let g:ctrlp_max_height=35 | |
| let twitvim_enable_python = 1 | |
| let twitvim_browser_cmd = 'firefox' | |
| cnoremap %% <C-R>=expand('%:h')<CR>/ | |
| nnoremap <leader><Tab> <C-^> | |
| nnoremap <leader>. <C-^> | |
| nnoremap gb B | |
| nnoremap gw W | |
| inoremap <leader>1 / | |
| cnoremap <leader>1 / | |
| inoremap {{ { | |
| }O | |
| au filetype ruby inoremap <buffer> {{ do | |
| endO | |
| let g:airline_powerline_fonts=1 | |
| inoremap jj | |
| cnoremap jj | |
| autocmd BufRead *.java setl efm=%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%# | |
| autocmd BufRead *.java call s:Config_ant() | |
| nnoremap ,,<Space> :nnoremap ,3 :w \\| < <backspace>cr><left><left><left><left> | |
| inoremap ,,<Space> <Esc>:inoremap ,3 <><left>Esc<right>:w \\| < <backspace>cr><left><left><left><left> | |
| nnoremap g} :ptnext<CR> | |
| nnoremap g{ :ptprev<CR> | |
| nnoremap <leader>g' } | |
| let g:airline#extensions#whitespace#trailing_format = 'Trail[%s]' | |
| let g:airline#extensions#whitespace#mixed_indent_format = 'Tab&Spc[%s]' | |
| "nnoremap g} execute 'normal :ptag ' . expand('<cword>') | |
| "nnoremap g{ execute '' | |
| "s/\s\+\w\+ \(\w\+\) \(\w\+\);/ public \1 get\u\2() {\r return \2;\r }\r\r public void set\u\2(\1 \2) {\r this.\2 = \2;\r }\r\r | |
| let g:loaded_unused_imports = '0.1' | |
| if v:version < 700 | |
| echoerr "unused-imports: this plugin requires vim >= 7." | |
| finish | |
| endif | |
| let s:matches_so_far = [] | |
| function! s:highlight_unused_imports(remove) | |
| call s:reset_unused_highlights() | |
| echom join(s:matches_so_far, '/') | |
| let linenr = 0 | |
| :highlight unusedimport ctermbg=darkred guibg=darkred | |
| while linenr < line("$") | |
| let linenr += 1 | |
| let line = getline(linenr) | |
| let lis = matchlist(line, 'import\%( static\)\? \(\w\+\.\)\+\(\w\+\);') | |
| if len(lis) > 0 | |
| let s = lis[2] | |
| let searchStr = '\(\/\/.*\)\@<!\.\@<!\<' . s . '\>' | |
| let linefound = search(searchStr, 'nw') | |
| if linefound == 0 | |
| if a:remove | |
| :exec linenr . 'd _' | |
| else | |
| call add(s:matches_so_far, matchadd('unusedimport', line)) | |
| endif | |
| endif | |
| endif | |
| endwhile | |
| endfunction | |
| function! s:reset_unused_highlights() | |
| for id in s:matches_so_far | |
| call matchdelete(id) | |
| endfor | |
| let s:matches_so_far = [] | |
| endfunction | |
| command! UnusedImports call s:highlight_unused_imports(0) | |
| command! UnusedImportsRemove call s:highlight_unused_imports(1) | |
| command! UnusedImportsReset call s:reset_unused_highlights() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment