Skip to content

Instantly share code, notes, and snippets.

@micimize
Created December 13, 2020 20:12
Show Gist options
  • Save micimize/e7f4b6a6bff956dbad35e6b0e4776b96 to your computer and use it in GitHub Desktop.
Save micimize/e7f4b6a6bff956dbad35e6b0e4776b96 to your computer and use it in GitHub Desktop.
Get NERDTreeTabs behavior, without the tabs
" https://github.com/jistr/vim-nerdtree-tabs
" display list of buffers like tabs
Plugin 'ap/vim-buftabline'
" claims to solve w/wq edge cases and I believe them
Plugin 'mhinz/vim-sayonara'
" automatically enter/exit paste on inhuman input speed
" added because paste disables abbreviations,
" unsure how important it is yet
Plugin 'roxma/vim-paste-easy'
" Returns the first window ID containing a file buffer
"
" Iterates through window numbers until the last (winnr('$')),
" Skipping special buffer types & preview windows
function! FirstFileWindowID()
let i = 1
while i <= winnr('$')
let bnum = winbufnr(i)
if bnum !=# -1 && getbufvar(bnum, '&buftype') ==# ''
\ && !getwinvar(i, '&previewwindow')
" TODO I don't know what excluding &hidden does in the original,
" but may be desirable for correctness
return win_getid(i)
endif
let i += 1
endwhile
return -1
endfunction
"tab movement (ctrl-n for next tab, ctrl-p for previous)
map <c-n> :call win_execute(FirstFileWindowID(), 'bnext')<CR>
map <c-p> :call win_execute(FirstFileWindowID(), 'bprev')<CR>
" tab-like :q behavior for buffers
" Prevent accidental closing of all buffers when doing :wq or :q
cnoreabbrev wq w<bar>Sayonara
cnoreabbrev q Sayonara
" make sure paste doesn't disable abbreviations,
" breaking the above
set nopaste
" TODO haven't gotten around to it yet, but should probably munge
" keybindings a bit regain the ability to replace current buffer
" change o to t as regular opening is now
" like open-in-tab behavior
" let NERDTreeMapOpenInTab='\t'
" let NERDTreeMapActivateNode='t'
@micimize
Copy link
Author

FirstFileWindowID derived from nerdtree's s:Opener._firstUsableWindow

@micimize
Copy link
Author

I would really like to see what a tight integration between tmux and vim would look like as an alternative to vim-contained systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment