scriptencoding utf-8 function! SpaceVim#default#SetOptions() abort " basic vim settiing if has('gui_running') set guioptions-=m " Hide menu bar. set guioptions-=T " Hide toolbar set guioptions-=L " Hide left-hand scrollbar set guioptions-=r " Hide right-hand scrollbar set guioptions-=b " Hide bottom scrollbar set showtabline=0 " Hide tabline if WINDOWS() " please install the font in 'Dotfiles\font' set guifont=DejaVu_Sans_Mono_for_Powerline:h11:cANSI:qDRAFT elseif OSX() set guifont=DejaVu\ Sans\ Mono\ for\ Powerline:h11 else set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 11 endif endif " indent use backspace delete indent, eol use backspace delete line at " begining start delete the char you just typed in if you do not use set " nocompatible ,you need this set backspace=indent,eol,start " Shou number and relativenumber set relativenumber set number " set fillchar hi VertSplit ctermbg=NONE guibg=NONE set fillchars+=vert:│ " hide cmd set noshowcmd " indent set autoindent set smartindent set cindent " show wildmenu set wildmenu " do not break words. set linebreak " tab options: set tabstop=4 set expandtab set softtabstop=4 set shiftwidth=4 " autoread set autoread " backup set backup set undofile set undolevels=1000 let g:data_dir = $HOME . '/.data/' let g:backup_dir = g:data_dir . 'backup' let g:swap_dir = g:data_dir . 'swap' let g:undo_dir = g:data_dir . 'undofile' if finddir(g:data_dir) ==# '' silent call mkdir(g:data_dir) endif if finddir(g:backup_dir) ==# '' silent call mkdir(g:backup_dir) endif if finddir(g:swap_dir) ==# '' silent call mkdir(g:swap_dir) endif if finddir(g:undo_dir) ==# '' silent call mkdir(g:undo_dir) endif unlet g:backup_dir unlet g:swap_dir unlet g:data_dir unlet g:undo_dir set undodir=$HOME/.data/undofile set backupdir=$HOME/.data/backup set directory=$HOME/.data/swap set nofoldenable " no fold enable set nowritebackup set matchtime=0 set ruler set showmatch set showmode "menuone: show the pupmenu when only one match set completeopt=menu,menuone,longest " disable preview scratch window, set complete=.,w,b,u,t " h: 'complete' set pumheight=15 " limit completion menu height set scrolloff=7 set incsearch set hlsearch set laststatus=2 set completeopt=longest,menu set wildignorecase set mouse= set hidden set ttimeout set ttimeoutlen=50 set background=dark endfunction function! SpaceVim#default#SetPlugins() abort call add(g:spacevim_plugin_groups, 'web') call add(g:spacevim_plugin_groups, 'lang') call add(g:spacevim_plugin_groups, 'edit') call add(g:spacevim_plugin_groups, 'ui') call add(g:spacevim_plugin_groups, 'tools') call add(g:spacevim_plugin_groups, 'checkers') call add(g:spacevim_plugin_groups, 'format') call add(g:spacevim_plugin_groups, 'chat') call add(g:spacevim_plugin_groups, 'git') call add(g:spacevim_plugin_groups, 'javascript') call add(g:spacevim_plugin_groups, 'ruby') call add(g:spacevim_plugin_groups, 'python') call add(g:spacevim_plugin_groups, 'scala') call add(g:spacevim_plugin_groups, 'lang#go') call add(g:spacevim_plugin_groups, 'lang#markdown') call add(g:spacevim_plugin_groups, 'scm') call add(g:spacevim_plugin_groups, 'editing') call add(g:spacevim_plugin_groups, 'indents') call add(g:spacevim_plugin_groups, 'navigation') call add(g:spacevim_plugin_groups, 'misc') call add(g:spacevim_plugin_groups, 'core') call add(g:spacevim_plugin_groups, 'unite') call add(g:spacevim_plugin_groups, 'github') if has('python3') call add(g:spacevim_plugin_groups, 'denite') endif call add(g:spacevim_plugin_groups, 'ctrlp') call add(g:spacevim_plugin_groups, 'autocomplete') if ! has('nvim') call add(g:spacevim_plugin_groups, 'vim') else call add(g:spacevim_plugin_groups, 'nvim') endif if OSX() call add(g:spacevim_plugin_groups, 'osx') endif if WINDOWS() call add(g:spacevim_plugin_groups, 'windows') endif if LINUX() call add(g:spacevim_plugin_groups, 'linux') endif endfunction function! SpaceVim#default#SetMappings() abort "mapping "全局映射 "也可以通过'za'打开或者关闭折叠 imap SpaceVim#mapping#tab() smap neosnippet#expandable_or_jumpable() ? "\(neosnippet_expand_or_jump)" : "\" inoremap SpaceVim#mapping#enter() inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\\\" : "\" inoremap pumvisible() ? "\\\" : "\" imap pumvisible() ? "\" : "" smap pumvisible() ? "\" : "" "Super paste it does not work "ino :set pastemui+mv'uV'v=:set nopaste "对于没有权限的文件使用 :w!!来保存 cnoremap w!! %!sudo tee > /dev/null % " cmap W!! w !sudo tee % >/dev/null " I can not understand " Save a file with sudo " http://forrst.com/posts/Use_w_to_sudo_write_a_file_with_Vim-uAN " 映射Ctrl+上下左右来切换窗口 nnoremap :wincmd l nnoremap :wincmd h nnoremap :wincmd k nnoremap :wincmd j if has('nvim') exe 'tnoremap :wincmd l' exe 'tnoremap :wincmd h' exe 'tnoremap :wincmd k' exe 'tnoremap :wincmd j' exe 'tnoremap :bprev' exe 'tnoremap :bnext' exe 'tnoremap ' endif "Quickly add empty lines nnoremap [ :put! =repeat(nr2char(10), v:count1) nnoremap ] :put =repeat(nr2char(10), v:count1) "Use jk switch to normal mode inoremap jk "]e or [e move current line ,count can be useed nnoremap [e :execute 'move -1-'. v:count1 nnoremap ]e :execute 'move +'. v:count1 "] or ] move current line to the end or the begin of current buffer nnoremap ] ddGp`` nnoremap ] ddggP`` vnoremap ] dGp`` vnoremap ] dggP`` "Ctrl+Shift+上下移动当前行 nnoremap :m .+1== nnoremap :m .-2== inoremap :m .+1==gi inoremap :m .-2==gi "上下移动选中的行 vnoremap :m '>+1gv=gv vnoremap :m '<-2gv=gv " download gvimfullscreen.dll from github, copy gvimfullscreen.dll to " the directory that has gvim.exe nnoremap :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0) " Start new line inoremap o " Improve scroll, credits: https://github.com/Shougo nnoremap zz (winline() == (winheight(0)+1) / 2) ? \ 'zt' : (winline() == 1) ? 'zb' : 'zz' noremap max([winheight(0) - 2, 1]) \ ."\".(line('w$') >= line('$') ? "L" : "H") noremap max([winheight(0) - 2, 1]) \ ."\".(line('w0') <= 1 ? "H" : "L") noremap (line("w$") >= line('$') ? "j" : "3\") noremap (line("w0") <= 1 ? "k" : "3\") " Select blocks after indenting xnoremap < >gv| " Use tab for indenting in visual mode xnoremap >gv| xnoremap >>_ nnoremap < <<_ " smart up and down nnoremap gj nnoremap gk " Select last paste nnoremap gp '`['.strpart(getregtype(), 0, 1).'`]' " Use Q format lines map Q gq " Navigate window nnoremap nnoremap x " Navigation in command line cnoremap cnoremap cnoremap " Fast saving nnoremap :w vnoremap :w cnoremap w " Tabs nnoremap g0 :tabfirst nnoremap g$ :tablast nnoremap gr :tabprevious " Remove spaces at the end of lines nnoremap , :silent! keeppatterns %substitute/\s\+$//e " C-r: Easier search and replace xnoremap :call VSetSearch():,$s/=@///gc function! s:VSetSearch() abort let temp = @s norm! gv"sy let @/ = '\V' . substitute(escape(@s, '/\'), '\n', '\\n', 'g') let @s = temp endfunction "irssi like hot key nnoremap :call tobur(1) nnoremap :call tobur(2) nnoremap :call tobur(3) nnoremap :call tobur(4) nnoremap :call tobur(5) nnoremap :call tobur("bnext") nnoremap :call tobur("bprev") call SpaceVim#mapping#def('nnoremap ','',':call chat#qq#OpenMsgWin()', \ 'Open qq chatting room','call chat#chatting#OpenMsgWin()') call SpaceVim#mapping#def('nnoremap ','',':call chat#weixin#OpenMsgWin()', \ 'Open weixin chatting room','call chat#chatting#OpenMsgWin()') call SpaceVim#mapping#def('nnoremap ','',':call chat#chatting#OpenMsgWin()', \ 'Open chatting room','call chat#chatting#OpenMsgWin()') call SpaceVim#mapping#def('nnoremap ','g=',':call zvim#format()','format current buffer','call zvim#format') call SpaceVim#mapping#def('nnoremap ', '', ':call zvim#util#CopyToClipboard()', \ 'Copy buffer absolute path to X11 clipboard','call zvim#util#CopyToClipboard()') call SpaceVim#mapping#def('nnoremap ', '', ':wincmd w', 'Switch to next window or tab','wincmd w') call SpaceVim#mapping#def('nnoremap ', '', ':wincmd p', 'Switch to previous window or tab','wincmd p') call SpaceVim#mapping#def('nnoremap ', 'q', ':call zvim#util#SmartClose()', \ 'Smart close windows', \ 'call zvim#util#SmartClose()') call SpaceVim#mapping#def('nnoremap ', 'gf', ':call zvim#gf()', 'Jump to a file under cursor', '') call SpaceVim#mapping#def('nnoremap ', 'gd', ':call SpaceVim#mapping#gd()', 'Goto declaration', '') endfunction fu! s:tobur(num) abort if index(get(g:,'spacevim_altmoveignoreft',[]), &filetype) == -1 if a:num ==# 'bnext' bnext elseif a:num ==# 'bprev' bprev else let ls = split(execute(':ls'), "\n") let buffers = [] for b in ls let nr = matchstr(b, '\d\+') call add(buffers, nr) endfor if len(buffers) >= a:num exec 'buffer ' . buffers[a:num - 1] endif endif endif endf function! SpaceVim#default#UseSimpleMode() abort endfunction " vim:set et sw=2: