2012-05-29 16:12:10 -04:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Important:
|
|
|
|
" This requries that you install https://github.com/amix/vimrc !
|
|
|
|
"
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" => GUI related
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Set font according to system
|
|
|
|
if has("mac") || has("macunix")
|
2015-12-08 08:19:59 -05:00
|
|
|
set gfn=Hack:h14,Source\ Code\ Pro:h15,Menlo:h15
|
2012-05-29 16:12:10 -04:00
|
|
|
elseif has("win16") || has("win32")
|
2015-12-08 08:19:59 -05:00
|
|
|
set gfn=Hack:h14,Source\ Code\ Pro:h12,Bitstream\ Vera\ Sans\ Mono:h11
|
2016-01-15 00:43:56 -05:00
|
|
|
elseif has("gui_gtk2")
|
|
|
|
set gfn=Hack\ 14,Source\ Code\ Pro\ 12,Bitstream\ Vera\ Sans\ Mono\ 11
|
2012-05-29 16:12:10 -04:00
|
|
|
elseif has("linux")
|
2016-01-15 00:43:56 -05:00
|
|
|
set gfn=Hack\ 14,Source\ Code\ Pro\ 12,Bitstream\ Vera\ Sans\ Mono\ 11
|
2013-07-13 12:07:32 -04:00
|
|
|
elseif has("unix")
|
2013-04-13 14:15:26 -04:00
|
|
|
set gfn=Monospace\ 11
|
2012-05-29 16:12:10 -04:00
|
|
|
endif
|
|
|
|
|
2012-08-24 18:00:53 -04:00
|
|
|
" Disable scrollbars (real hackers don't use scrollbars for navigation!)
|
|
|
|
set guioptions-=r
|
|
|
|
set guioptions-=R
|
|
|
|
set guioptions-=l
|
|
|
|
set guioptions-=L
|
|
|
|
|
2013-12-29 06:31:16 -05:00
|
|
|
" Colorscheme
|
2016-05-14 08:22:32 -04:00
|
|
|
set background=dark
|
|
|
|
colorscheme peaksea
|
2013-12-29 06:31:16 -05:00
|
|
|
|
2012-05-29 16:12:10 -04:00
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" => Fast editing and reloading of vimrc configs
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2012-05-30 12:54:47 -04:00
|
|
|
map <leader>e :e! ~/.vim_runtime/my_configs.vim<cr>
|
2016-10-24 16:00:55 -04:00
|
|
|
autocmd! bufwritepost ~/.vim_runtime/my_configs.vim source ~/.vim_runtime/my_configs.vim
|
2012-05-29 16:12:10 -04:00
|
|
|
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" => Turn persistent undo on
|
|
|
|
" means that you can undo even when you close a buffer/VIM
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
try
|
2012-05-30 12:54:47 -04:00
|
|
|
set undodir=~/.vim_runtime/temp_dirs/undodir
|
2012-05-29 16:12:10 -04:00
|
|
|
set undofile
|
|
|
|
catch
|
|
|
|
endtry
|
|
|
|
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" => Command mode related
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Smart mappings on the command line
|
|
|
|
cno $h e ~/
|
|
|
|
cno $d e ~/Desktop/
|
|
|
|
cno $j e ./
|
|
|
|
cno $c e <C-\>eCurrentFileDir("e")<cr>
|
|
|
|
|
|
|
|
" $q is super useful when browsing on the command line
|
|
|
|
" it deletes everything until the last slash
|
|
|
|
cno $q <C-\>eDeleteTillSlash()<cr>
|
|
|
|
|
|
|
|
" Bash like keys for the command line
|
|
|
|
cnoremap <C-A> <Home>
|
|
|
|
cnoremap <C-E> <End>
|
|
|
|
cnoremap <C-K> <C-U>
|
|
|
|
|
|
|
|
cnoremap <C-P> <Up>
|
|
|
|
cnoremap <C-N> <Down>
|
|
|
|
|
2012-05-30 12:54:47 -04:00
|
|
|
" Map ½ to something useful
|
|
|
|
map ½ $
|
|
|
|
cmap ½ $
|
|
|
|
imap ½ $
|
|
|
|
|
2012-05-29 16:12:10 -04:00
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
2012-05-29 17:32:24 -04:00
|
|
|
" => Parenthesis/bracket
|
2012-05-29 16:12:10 -04:00
|
|
|
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
vnoremap $1 <esc>`>a)<esc>`<i(<esc>
|
|
|
|
vnoremap $2 <esc>`>a]<esc>`<i[<esc>
|
|
|
|
vnoremap $3 <esc>`>a}<esc>`<i{<esc>
|
|
|
|
vnoremap $$ <esc>`>a"<esc>`<i"<esc>
|
|
|
|
vnoremap $q <esc>`>a'<esc>`<i'<esc>
|
|
|
|
vnoremap $e <esc>`>a"<esc>`<i"<esc>
|
|
|
|
|
|
|
|
" Map auto complete of (, ", ', [
|
|
|
|
inoremap $1 ()<esc>i
|
|
|
|
inoremap $2 []<esc>i
|
|
|
|
inoremap $3 {}<esc>i
|
|
|
|
inoremap $4 {<esc>o}<esc>O
|
|
|
|
inoremap $q ''<esc>i
|
|
|
|
inoremap $e ""<esc>i
|
|
|
|
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" => General abbreviations
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
iab xdate <c-r>=strftime("%d/%m/%y %H:%M:%S")<cr>
|
|
|
|
|
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" => Omni complete functions
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
|
|
|
|
|
|
|
|
|
2017-04-01 08:29:02 -04:00
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" => Ack searching and cope displaying
|
|
|
|
" requires ack.vim - it's much better than vimgrep/grep
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" Use the the_silver_searcher if possible (much faster than Ack)
|
|
|
|
if executable('ag')
|
|
|
|
let g:ackprg = 'ag --vimgrep --smart-case'
|
|
|
|
endif
|
|
|
|
|
|
|
|
" When you press gv you Ack after the selected text
|
|
|
|
vnoremap <silent> gv :call VisualSelection('gv', '')<CR>
|
|
|
|
|
|
|
|
" Open Ack and put the cursor in the right position
|
|
|
|
map <leader>g :Ack
|
|
|
|
|
|
|
|
" When you press <leader>r you can search and replace the selected text
|
|
|
|
vnoremap <silent> <leader>r :call VisualSelection('replace', '')<CR>
|
|
|
|
|
|
|
|
" Do :help cope if you are unsure what cope is. It's super useful!
|
|
|
|
"
|
|
|
|
" When you search with Ack, display your results in cope by doing:
|
|
|
|
" <leader>cc
|
|
|
|
"
|
|
|
|
" To go to the next search result do:
|
|
|
|
" <leader>n
|
|
|
|
"
|
|
|
|
" To go to the previous search results do:
|
|
|
|
" <leader>p
|
|
|
|
"
|
|
|
|
map <leader>cc :botright cope<cr>
|
|
|
|
map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
|
|
|
|
map <leader>n :cn<cr>
|
|
|
|
map <leader>p :cp<cr>
|
|
|
|
|
|
|
|
|
2012-05-29 16:12:10 -04:00
|
|
|
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
" => Helper functions
|
|
|
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
|
|
|
func! DeleteTillSlash()
|
|
|
|
let g:cmd = getcmdline()
|
|
|
|
|
|
|
|
if has("win16") || has("win32")
|
|
|
|
let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\]\\).*", "\\1", "")
|
|
|
|
else
|
|
|
|
let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*", "\\1", "")
|
|
|
|
endif
|
|
|
|
|
|
|
|
if g:cmd == g:cmd_edited
|
|
|
|
if has("win16") || has("win32")
|
|
|
|
let g:cmd_edited = substitute(g:cmd, "\\(.*\[\\\\\]\\).*\[\\\\\]", "\\1", "")
|
|
|
|
else
|
|
|
|
let g:cmd_edited = substitute(g:cmd, "\\(.*\[/\]\\).*/", "\\1", "")
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
return g:cmd_edited
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
func! CurrentFileDir(cmd)
|
|
|
|
return a:cmd . " " . expand("%:p:h") . "/"
|
|
|
|
endfunc
|
2017-04-01 08:29:02 -04:00
|
|
|
|
|
|
|
function! CmdLine(str)
|
|
|
|
exe "menu Foo.Bar :" . a:str
|
|
|
|
emenu Foo.Bar
|
|
|
|
unmenu Foo
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
function! VisualSelection(direction, extra_filter) range
|
|
|
|
let l:saved_reg = @"
|
|
|
|
execute "normal! vgvy"
|
|
|
|
|
|
|
|
let l:pattern = escape(@", "\\/.*'$^~[]")
|
|
|
|
let l:pattern = substitute(l:pattern, "\n$", "", "")
|
|
|
|
|
|
|
|
if a:direction == 'gv'
|
|
|
|
call CmdLine("Ack '" . l:pattern . "' " )
|
|
|
|
elseif a:direction == 'replace'
|
|
|
|
call CmdLine("%s" . '/'. l:pattern . '/')
|
|
|
|
endif
|
|
|
|
|
|
|
|
let @/ = l:pattern
|
|
|
|
let @" = l:saved_reg
|
|
|
|
endfunction
|
|
|
|
|
|
|
|
|