Created
June 12, 2011 23:29
-
-
Save joepestro/1022126 to your computer and use it in GitHub Desktop.
Playing around with a minimap toggle for vim. When activated, gives an overview of the current window and highlights the text that was in the visible area. Still needs some tweaking.
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
function! ToggleMinimap() | |
if exists("s:isMini") && s:isMini == 0 | |
let s:isMini = 1 | |
else | |
let s:isMini = 0 | |
end | |
if (s:isMini == 0) | |
" save current visible lines | |
let s:firstLine = line("w0") | |
let s:lastLine = line("w$") | |
" resize each window | |
" windo let w=winwidth(0)*12 | exe "set winwidth=" . w | |
" windo let h=winheight(0)*12 | exe "set winheight=" . h | |
" don't change window size | |
let c = &columns * 12 | |
let l = &lines * 12 | |
exe "set columns=" . c | |
exe "set lines=" . l | |
" make font small | |
set guifont=ProggyTiny:h1 | |
" highlight lines which were visible | |
let s:lines = "" | |
for i in range(s:firstLine, s:lastLine) | |
let s:lines = s:lines . "\\%" . i . "l" | |
if i < s:lastLine | |
let s:lines = s:lines . "\\|" | |
endif | |
endfor | |
exe 'match Visible /' . s:lines . '/' | |
hi Visible guibg=lightblue guifg=black term=bold | |
else | |
set guifont=Menlo:h12 | |
hi clear Visible | |
endif | |
endfunction | |
command! ToggleMinimap call ToggleMinimap() | |
nnoremap m :ToggleMinimap<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@keflavich The "zoomed out" font is hardcoded as ProggyTiny, try installing or replace with a different small font. I'll see what I can do to clean this up :)