Created
August 17, 2012 20:14
-
-
Save dahu/3382218 to your computer and use it in GitHub Desktop.
Toggle display of current div in statusline
This file contains hidden or 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
| let s:orig_statusline = &statusline | |
| function! HTMLCurrentDivId() | |
| let m = searchpos('<\s*div.\{-}id\s*=\s*"\([^"]*\)"', 'bnWp') | |
| if m[2] == 2 | |
| return matchlist(getline(m[0]), 'id\s*=\s*"\([^"]*\)"')[1] | |
| else | |
| return '' | |
| endif | |
| endfunction | |
| function! ToggleStatusLineCurrentDiv() | |
| if s:orig_statusline == &statusline | |
| let statusline = &statusline.' \%{HTMLCurrentDivId()}' | |
| else | |
| let statusline = s:orig_statusline | |
| endif | |
| exe "set statusline=".escape(statusline, ' ') | |
| endfunction | |
| nnoremap <silent> <leader>x :call ToggleStatusLineCurrentDiv()<cr> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment