" Use Q to intelligently close a window 
" (if there are multiple windows into the same buffer)
" or kill the buffer entirely if it's the last window looking into that buffer
function! CloseWindowOrKillBuffer()
  if(bufwinnr('%')) > 1
    wincmd c
  else
    bdelete
  endif
endfunction

nnoremap <silent> Q :call CloseWindowOrKillBuffer()<CR>

" Use Q to intelligently close a window 
" (if there are multiple windows into the same buffer)
" or kill the buffer entirely if it's the last window looking into that buffer
function! CloseWindowOrKillBuffer()
  let number_of_windows_to_this_buffer = len(filter(range(1, winnr('$')), "winbufnr(v:val) == bufnr('%')"))

  if number_of_windows_to_this_buffer > 1
    wincmd c
  else
    bdelete
  endif
endfunction

nnoremap <silent> Q :call CloseWindowOrKillBuffer()<CR>

Improve window killer (Q) - close window if multiple windows to same buffer exist
Improve window killer (Q) - close window if multiple windows to same buffer exist

martco/yadr,hophacker/dotfiles,tripl3inf/dotfiles,negativo/dotfiles-2,uhjish/dotfiles,minhoolee/skwp-dotfiles,nyxwulf/dotfiles,hophacker/dotfiles,andrewSC/dotfiles,tokeryberg/dotfiles-2,kdheepak89/yadr-dotfiles,javigon/dotfiles,kylewest/yadr,rchampourlier/dotfiles,valentinzberea/dotfiles-yadr,codedecay/dotfiles-1,1gitGrey/dotfiles-1,gnpkrish/yadr,walkleyn/dotfiles,sangtt/mdotfiles,valentinzberea/dotfiles-yadr,agamble/dotfiles,ChrisMcKenzie/dotfiles,chenhoward/dotfiles,gupta-tarun/dotfiles,uhjish/dotfiles,tyok/dotfiles,koheku/dotfiles,marcvreuls/dotfiles,ashlynbaum/dotfiles,joeyyang/yadr,skjerven/dotfiles,kierangraham/dotfiles,nrolland/dotfiles,lyanderson/dotfiles,davepgreene/yadr,NikitaAvvakumov/dotfiles,tullie/yadr-tm,argami/dotfiles,ds82/dotfiles,Jojo-Jojovich/dotfiles,ofer987/dotfiles,kierangraham/dotfiles,tmullen/dotfiles,jameszaghini/dotfiles,zelga/dotfiles,olslash/dotfiles,ccll/dotfiles,bionix/dotfiles-1,eesdil/yadr,nkgm/dotfiles,bobek/dotfiles,pulni/mac_dotfiles,uhjish/dotfiles,lfilho/dotfiles,ay65535/yadr,rockymontana/skwp-dotfiles,eywalker/walkspace,ofer987/dotfiles,ay65535/yadr,akitaonrails/dotfiles,akitaonrails/dotfiles,daxgames/dotfiles,minhoolee/skwp-dotfiles,sandeepjain/dotfiles,kerbyfc/kdr,katgironpe/dotfiles,pairshaped/dotfiles,barodeur/dotfiles,andrewSC/dotfiles,renoirb/ubuntu-yadr,hulajesus/dotfiles,rrmartins/my_yadr,fongoses/dotfiles,ktemkin/dotfiles,hulajesus/dotfiles,joesus/dotfiles,diego-oliveira/dotfiles-1,flyingfsck/dotfiles,hunterowens/dotfiles-2,fabiopelosin/dotfiles,davidjaw/dotfiles,sangtt/mdotfiles,plribeiro3000/dotfiles,giorni/dotfiles,ohnorobo/dotfiles,Xiaobin0860/dotfiles,neilor/dotfiles,hderms/dotfiles,41407/dotfiles,cantoraz/yadr,pietia/yadr,tkuichooseyou/dotfiles,tmullen/dotfiles,swinstanley/dotfiles-1,jf87/dotfiles-yadr,rockwarrior/dotfiles,mrap/dotfiles,tyok/dotfiles,andreazevedo/mac_dotfiles,dsimmons/dotfiles-old,nyxwulf/dotfiles,gnpkrish/yadr,plribeiro3000/dotfiles,nkgm/dotfiles,talbright/skwp-dotfiles,diego9627/dotfiles,Sumukh/dotfiles,mcmonkeyman/mcmonkeymans-fork-o-dotfiles,mrap/linux-dotfiles,mente/dotfiles,lyanderson/dotfiles,josanastrid/dotfiles,tigershen23/dotfiles,argami/dotfiles,1gitGrey/dotfiles-1,diego-oliveira/dotfiles-1,summera/yadr-alt,lhrkkk/yadr,fayimora/dotfiles,stinoga/dotfiles-1,captainmike/dotfiles,zhenyuy-fb/dotfiles,dsimmons/dotfiles-old,Witos/dotfiles,stevenbarragan/dotfiles,pulni/mac_dotfiles,tallamjr/yadr-fork,rockwarrior/dotfiles,ChrisMcKenzie/dotfiles,uni380/dotfiles,romansalin/dotfiles,tullie/yadr-tm,Witos/dotfiles,davepgreene/yadr,tyok/dotfiles,aqibmushtaq/dotfiles,btroo/dotfiles,lhrkkk/yadr,kqyang/dotfiles,skwp/dotfiles,kerbyfc/kdr,gupta-tarun/dotfiles,robinrob/framework,ttriggs/dotfiles,negativo/dotfiles-2,mente/dotfiles,thekindofme/dotfiles,ktemkin/dotfiles,fernandoaleman/yadr,argyakrivos/dotfiles,ohnorobo/dotfiles,uhjish/dotfiles,eywalker/walkspace,jf87/dotfiles-yadr,andrewSC/dotfiles,tallamjr/yadr-fork,qianthinking/dotfiles,pairshaped/dotfiles,swinstanley/dotfiles-1,tripl3inf/dotfiles,ptgamr/dotfiles-2,ccll/dotfiles,lhrkkk/dotfiles_old_2015_11_01,stinoga/dotfiles-1,uhjish/dotfiles,epelz/dotfiles,goorockey/dotfiles,wesleyskap/dotfiles-1,fayimora/dotfiles-1,kdheepak89/yadr-dotfiles,jby/dotfiles,xytis/dotfiles,periodic1236/dotfiles,fogisland/dotfiles,NikitaAvvakumov/dotfiles,ernestonakamura/dotfiles,bionix/dotfiles-1,diego9627/dotfiles,atsapov/dotfiles,sztupy/dotfiles,swanandp/dotfiles,pulni/mac_dotfiles,kanche/dotfiles,333fred/dotfiles_yadr,mrap/linux-dotfiles,xkonni/dotfiles,daxgames/dotfiles,kylewest/yadr,leiklier/dotfiles,ds82/dotfiles,tokeryberg/dotfiles-2,btroo/dotfiles,andyattebery/dotfiles,jo-tez/yadr,joesus/dotfiles,41407/dotfiles,periodic1236/dotfiles,lhrkkk/yadr,svdberg/dotfiles,trongrg/dotfiles,fongoses/dotfiles,nikolai-b/dotfiles,martco/yadr,davidjaw/dotfiles,kqyang/dotfiles,Sumukh/dotfiles,uhjish/dotfiles,walkleyn/dotfiles,mba811/dotfiles,lfilho/dotfiles,tientun/dotfiles,nikolai-b/dotfiles,lhrkkk/dotfiles_old_2015_11_01,ashlynbaum/dotfiles,nrolland/dotfiles,ramiroaraujo/dotfiles,swanandp/dotfiles,brazencavalier/dotfiles,K3yChain/yadr,goorockey/dotfiles,jckdrpr/dotfiles-1,denyago/dotfiles,wesson-yi/dotfiles,ernestonakamura/dotfiles,LouTheBrew/dotfiles,skjerven/dotfiles,pswaminathan/dotfiles,pswaminathan/dotfiles,SherrySeibel/dotfiles,koheku/dotfiles,RyanMacG/dotfiles-1,jckdrpr/dotfiles-1,rrmartins/my_yadr,xvaara/dotfiles,Jojo-Jojovich/dotfiles,renoirb/ubuntu-yadr,thekindofme/dotfiles,LouTheBrew/dotfiles,talbright/skwp-dotfiles,mba811/dotfiles,ChrisMcKenzie/dotfiles,zhang-ning/yadr,backus/yadr,kanche/dotfiles,pietia/yadr,yjlintw/dotfiles,uhjish/dotfiles,wesson-yi/dotfiles,fogisland/dotfiles,jameszaghini/dotfiles,hunterowens/dotfiles-2,eesdil/yadr,j-mcnally/dotfiles,robinrob/framework,barodeur/dotfiles,eesdil/yadr,pietia/yadr,nakolkin/dotfiles,hderms/dotfiles,rhysyngsun/dotfiles,tientun/dotfiles,minhoolee/skwp-dotfiles,mente/dotfiles,javigon/dotfiles,denyago/dotfiles,qianthinking/dotfiles,wesson-yi/dotfiles,alex-wood/dotfiles,j-mcnally/dotfiles,raiseandfall/vim-tmux-dotfiles,patarra/dotfiles,alex-wood/dotfiles,mcmonkeyman/mcmonkeymans-fork-o-dotfiles,pruan-rht/dotfiles,SherrySeibel/dotfiles,rchampourlier/dotfiles,auser/yadr,hunterowens/dotfiles-2,renoirb/ubuntu-yadr,raiseandfall/vim-tmux-dotfiles,patarra/dotfiles,sideci-sample/sideci-sample-dotfiles,fabiopelosin/dotfiles,drajguru/dotfiles,minhoolee/skwp-dotfiles,kirthar/dotfiles,tosbourn/dotfiles,fayimora/dotfiles-1,jby/dotfiles,ds82/dotfiles,zhang-ning/yadr,sideci-sample/sideci-sample-dotfiles,333fred/dotfiles_yadr,sevenadrian/dotfiles,codedecay/dotfiles-1,zhenyuy-fb/dotfiles,pietia/yadr,atsapov/dotfiles,neanias/dotfiles,RyanMacG/dotfiles-1,K3yChain/yadr,pruan-rht/dotfiles,kerbyfc/kdr,aqibmushtaq/dotfiles,phongjalvn/dotfiles,skwp/dotfiles,bobek/dotfiles,sayar/dotfiles,nyxwulf/dotfiles,KonradJanica/yadr-tm,xytis/dotfiles,uhjish/dotfiles,chenhoward/dotfiles,renoirb/ubuntu-yadr,juvoni/dotfiles-1,kierangraham/dotfiles,wesleyskap/dotfiles-1,ignasi/dotfiles,barodeur/dotfiles,katgironpe/dotfiles,ashlynbaum/dotfiles,joeyyang/yadr,marcvreuls/dotfiles,bob2314/dotfiles-1,fayimora/dotfiles,lfilho/dotfiles,mdarnall/dotfiles,cfabianski/yadr-dotfiles,yjlintw/dotfiles,xkonni/dotfiles,skjerven/dotfiles,andyattebery/dotfiles,neilor/dotfiles,rbrcurtis/yadr,kirthar/dotfiles,c-j-j/dotfiles-yadr,sayar/dotfiles,fayimora/vps_dotfiles,nakolkin/dotfiles,argyakrivos/dotfiles,KonradJanica/yadr-tm,summera/yadr-alt,kierangraham/dotfiles,GiorgioNatili/vim,epelz/dotfiles,josanastrid/dotfiles,jckdrpr/dotfiles-1,ptgamr/dotfiles-2,333fred/dotfiles_yadr,tonynguyen68/dotfiles,gizero/dotfiles,demis001/dotfiles,aeikenberry/yardr_dotfiles,theone4ever/dotfiles,sevenadrian/dotfiles,flyingfsck/dotfiles,ramiroaraujo/dotfiles,fayimora/vps_dotfiles,rhysyngsun/dotfiles,cfabianski/yadr-dotfiles,tosbourn/dotfiles,mdarnall/dotfiles,fayimora/vps_dotfiles,mrap/dotfiles,olslash/dotfiles,michaeljacobdavis/dotfiles-yadr,michaeljacobdavis/dotfiles-yadr,juvoni/dotfiles-1,mpeter/dotfiles,phongjalvn/dotfiles,giorni/dotfiles,xvaara/dotfiles,xytis/dotfiles,bcrochet/dotfiles,bob2314/dotfiles-1,agamble/dotfiles,qianthinking/dotfiles,phongjalvn/dotfiles,c-j-j/dotfiles-yadr,captainmike/dotfiles,leiklier/dotfiles,auser/yadr,demis001/dotfiles,tigershen23/dotfiles,trongrg/dotfiles,aeikenberry/yardr_dotfiles,rockymontana/skwp-dotfiles,fayimora/dotfiles-1,tkuichooseyou/dotfiles,bcrochet/dotfiles,stevenbarragan/dotfiles,drajguru/dotfiles,cantoraz/yadr,jo-tez/yadr,ttriggs/dotfiles,romansalin/dotfiles,lhrkkk/yadr,uni380/dotfiles,GiorgioNatili/vim,fernandoaleman/yadr,tonynguyen68/dotfiles,svdberg/dotfiles,theone4ever/dotfiles,macat/dotfiles,ignasi/dotfiles,yjlintw/dotfiles,mpeter/dotfiles,Xiaobin0860/dotfiles,rbrcurtis/yadr,backus/yadr,uhjish/dotfiles,gizero/dotfiles,gnpkrish/yadr,kqyang/dotfiles,zelga/dotfiles,neanias/dotfiles,andreazevedo/mac_dotfiles,brazencavalier/dotfiles,sandeepjain/dotfiles,sztupy/dotfiles