Last active
November 23, 2016 16:39
-
-
Save statox/81cc7cecadca2bcfb038944ee47b20dd to your computer and use it in GitHub Desktop.
Playing with vim folds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
augroup pythonFold | |
autocmd BufReadPre *.py setlocal foldmethod=indent | |
autocmd CursorMovedI *.py call PinFold() | |
autocmd CursorMoved *.py call PinFold() | |
augroup END | |
function! PinFold() | |
" save current position | |
let saveCursor = getcurpos() | |
" Go to upper split, open all folds and go to the same line as bottom split | |
wincmd k | |
normal! zR | |
execute "normal! " . saveCursor[1] . "G" | |
" Go to the beginning of the fold and put the line in the middle of the upper split | |
normal! [z | |
normal! z. | |
" Go back to bottom split and restore position | |
wincmd j | |
call setpos('.', saveCursor) | |
endfunction |
Author
statox
commented
Nov 23, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment