mirror of
https://github.com/amix/vimrc
synced 2025-07-01 04:35:00 +08:00
Initial commit
This commit is contained in:
145
vimrcs/extended.vim
Normal file
145
vimrcs/extended.vim
Normal file
@ -0,0 +1,145 @@
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" Important:
|
||||
" This requries that you install https://github.com/amix/vimrc !
|
||||
"
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => GUI related
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
set background=dark
|
||||
|
||||
if has("gui_running")
|
||||
colorscheme peaksea
|
||||
else
|
||||
colorscheme ir_black
|
||||
endif
|
||||
|
||||
" Set font according to system
|
||||
if has("mac") || has("macunix")
|
||||
set gfn=Menlo:h14
|
||||
set shell=/bin/bash
|
||||
elseif has("win16") || has("win32")
|
||||
set gfn=Bitstream\ Vera\ Sans\ Mono:h10
|
||||
elseif has("linux")
|
||||
set gfn=Monospace\ 10
|
||||
set shell=/bin/bash
|
||||
endif
|
||||
|
||||
" Open MacVim in fullscreen mode
|
||||
if has("gui_macvim")
|
||||
set fuoptions=maxvert,maxhorz
|
||||
au GUIEnter * set fullscreen
|
||||
endif
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Fast editing and reloading of vimrc configs
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
if has("win16") || has("win32")
|
||||
map <leader>e :e! ~/_vim_runtime/vimrcs/vimrc_my_configs.vim<cr>
|
||||
autocmd! bufwritepost vimrc source ~/_vim_runtime/vimrcs/vimrc_my_configs.vim
|
||||
else
|
||||
map <leader>e :e! ~/.vim_runtime/vimrcs/vimrc_my_configs.vim<cr>
|
||||
autocmd! bufwritepost vimrc source ~/.vim_runtime/vimrcs/vimrc_my_configs.vim
|
||||
endif
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Turn persistent undo on
|
||||
" means that you can undo even when you close a buffer/VIM
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
try
|
||||
if has("win16") || has("win32")
|
||||
set undodir=~/_vim_runtime/temp_dirs/undodir
|
||||
else
|
||||
set undodir=~/.vim_runtime/temp_dirs/undodir
|
||||
endif
|
||||
|
||||
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>
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => Parenthesis/bracket expanding
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
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
|
||||
inoremap $t <><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
|
||||
|
||||
|
||||
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
" => 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
|
Reference in New Issue
Block a user