this repo has no description

Cleanup .vimrc

Changed files
+77 -79
vim
plugin
+1 -1
gvimrc
···
nmap <S-ESC> :close<CR>
" Buffers
-
noremap <silent> <C-D> :Bclose<CR>
+
noremap <silent> <C-D> :Bclose<CR>
+72
vim/plugin/bclose.vim
···
+
" Delete buffer while keeping window layout (don't close buffer's windows).
+
" Version 2008-11-18 from http://vim.wikia.com/wiki/VimTip165
+
if v:version < 700 || exists('loaded_bclose') || &cp
+
finish
+
endif
+
let loaded_bclose = 1
+
if !exists('bclose_multiple')
+
let bclose_multiple = 1
+
endif
+
+
" Display an error message.
+
function! s:Warn(msg)
+
echohl ErrorMsg
+
echomsg a:msg
+
echohl NONE
+
endfunction
+
+
" Command ':Bclose' executes ':bd' to delete buffer in current window.
+
" The window will show the alternate buffer (Ctrl-^) if it exists,
+
" or the previous buffer (:bp), or a blank buffer if no previous.
+
" Command ':Bclose!' is the same, but executes ':bd!' (discard changes).
+
" An optional argument can specify which buffer to close (name or number).
+
function! s:Bclose(bang, buffer)
+
if empty(a:buffer)
+
let btarget = bufnr('%')
+
elseif a:buffer =~ '^\d\+$'
+
let btarget = bufnr(str2nr(a:buffer))
+
else
+
let btarget = bufnr(a:buffer)
+
endif
+
if btarget < 0
+
call s:Warn('No matching buffer for '.a:buffer)
+
return
+
endif
+
if empty(a:bang) && getbufvar(btarget, '&modified')
+
call s:Warn('No write since last change for buffer '.btarget.' (use :Bclose!)')
+
return
+
endif
+
" Numbers of windows that view target buffer which we will delete.
+
let wnums = filter(range(1, winnr('$')), 'winbufnr(v:val) == btarget')
+
if !g:bclose_multiple && len(wnums) > 1
+
call s:Warn('Buffer is in multiple windows (use ":let bclose_multiple=1")')
+
return
+
endif
+
let wcurrent = winnr()
+
for w in wnums
+
execute w.'wincmd w'
+
let prevbuf = bufnr('#')
+
if prevbuf > 0 && buflisted(prevbuf) && prevbuf != w
+
buffer #
+
else
+
bprevious
+
endif
+
if btarget == bufnr('%')
+
" Numbers of listed buffers which are not the target to be deleted.
+
let blisted = filter(range(1, bufnr('$')), 'buflisted(v:val) && v:val != btarget')
+
" Listed, not target, and not displayed.
+
let bhidden = filter(copy(blisted), 'bufwinnr(v:val) < 0')
+
" Take the first buffer, if any (could be more intelligent).
+
let bjump = (bhidden + blisted + [-1])[0]
+
if bjump > 0
+
execute 'buffer '.bjump
+
else
+
execute 'enew'.a:bang
+
endif
+
endif
+
endfor
+
execute 'bdelete'.a:bang.' '.btarget
+
execute wcurrent.'wincmd w'
+
endfunction
+
+
command! -bang -complete=buffer -nargs=? Bclose call s:Bclose('<bang>', '<args>')
+4 -78
vimrc
···
map <silent> <leader><space> :nohlsearch<CR>
nmap <C-M> :nohlsearch<CR>
-
" Formatting
-
map <leader>ffa mzgg=G`z<CR>
+
" Formatting and cleaning
+
map <leader>ff mzgg=G`z<CR>
+
map <leader>fc :Clean<CR>
" Split window
nmap <leader>wsh :topleft vnew<CR>
···
highlight Pmenu ctermbg=238 gui=bold
let g:SuperTabDefaultCompletionType = "context"
+
let g:SuperTabDefaultCompletionType = "<c-n>"
let g:SuperTabMappingForward = '<C-Tab>'
let g:SuperTabMappingBackward = '<S-Tab>'
···
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
cmap w!! %!sudo tee > /dev/null %
-
command! Todo noautocmd vimgrep /TODO\|FIXME/j **/*.{py,rb,css,js,coffee,c,cpp,c++,cxx,h,hpp,h++,hxx,scss,sass} | cw
-
command! Clean %s/\s\+$//e | nohlsearch
command! W w !sudo tee % > /dev/null
-
-
" Cheat!
-
command! -complete=file -nargs=+ Cheat call s:cheat(<f-args>)
-
function! s:cheat(command)
-
botright new
-
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
-
execute 'silent $read !cheat '.escape(a:command,'%#')
-
setlocal nomodifiable
-
1
-
endfunction
-
-
if !exists(":DiffOrig")
-
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis | wincmd p | diffthis
-
endif
-
-
"delete the buffer; keep windows; create a scratch buffer if no buffers left
-
function! s:Kwbd(kwbdStage)
-
if(a:kwbdStage == 1)
-
if(!buflisted(winbufnr(0)))
-
bd!
-
return
-
endif
-
let s:kwbdBufNum = bufnr("%")
-
let s:kwbdWinNum = winnr()
-
windo call s:Kwbd(2)
-
execute s:kwbdWinNum . 'wincmd w'
-
let s:buflistedLeft = 0
-
let s:bufFinalJump = 0
-
let l:nBufs = bufnr("$")
-
let l:i = 1
-
while(l:i <= l:nBufs)
-
if(l:i != s:kwbdBufNum)
-
if(buflisted(l:i))
-
let s:buflistedLeft = s:buflistedLeft + 1
-
else
-
if(bufexists(l:i) && !strlen(bufname(l:i)) && !s:bufFinalJump)
-
let s:bufFinalJump = l:i
-
endif
-
endif
-
endif
-
let l:i = l:i + 1
-
endwhile
-
if(!s:buflistedLeft)
-
if(s:bufFinalJump)
-
windo if(buflisted(winbufnr(0))) | execute "b! " . s:bufFinalJump | endif
-
else
-
enew
-
let l:newBuf = bufnr("%")
-
windo if(buflisted(winbufnr(0))) | execute "b! " . l:newBuf | endif
-
endif
-
execute s:kwbdWinNum . 'wincmd w'
-
endif
-
if(buflisted(s:kwbdBufNum) || s:kwbdBufNum == bufnr("%"))
-
execute "bd! " . s:kwbdBufNum
-
endif
-
if(!s:buflistedLeft)
-
set buflisted
-
set bufhidden=delete
-
set buftype=
-
setlocal noswapfile
-
endif
-
else
-
if(bufnr("%") == s:kwbdBufNum)
-
let prevbufvar = bufnr("#")
-
if(prevbufvar > 0 && buflisted(prevbufvar) && prevbufvar != s:kwbdBufNum)
-
b #
-
else
-
bn
-
endif
-
endif
-
endif
-
endfunction
-
-
command! Bclose call s:Kwbd(1)