Skip to content

Instantly share code, notes, and snippets.

@wolever
Created February 3, 2015 20:50
Show Gist options
  • Save wolever/46f2c2cfcabf431679a6 to your computer and use it in GitHub Desktop.
Save wolever/46f2c2cfcabf431679a6 to your computer and use it in GitHub Desktop.
:Conly Vim command to close all windows in the current column.
" :Co[nly] closes all other windows in the current column.
" For example, if the cursor is in the "cur" window, below, windows 1, 2, and
" 4 will be closed:
" +-------+ +-------+
" | win 1 | | |
" +-------+ | |
" | win 2 | | |
" +-------+ --> :Conly --> | cur |
" | cur | | |
" +-------+ | |
" | win 4 | | |
" +-------+ +-------+
fun! Conly()
for dir in ['j', 'k']
while 1
let cur = winnr()
execute "normal \<c-w>".dir
if winnr() == cur
break
endif
close
endwhile
endfor
endfun
command! Conly call Conly()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment