Skip to content

Instantly share code, notes, and snippets.

@joepestro
Created June 12, 2011 23:29
Show Gist options
  • Save joepestro/1022126 to your computer and use it in GitHub Desktop.
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.
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>
@keflavich
Copy link

Interested in this, but the only effect it had was to make my window bigger and hide all the text.

@joepestro
Copy link
Author

@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 :)

@zhouzhuojie
Copy link

Could you give us a screenshot? @joepestro

@joepestro
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment