Skip to content

Instantly share code, notes, and snippets.

@AndrewRadev
Created June 19, 2012 16:27
Show Gist options
  • Save AndrewRadev/2955105 to your computer and use it in GitHub Desktop.
Save AndrewRadev/2955105 to your computer and use it in GitHub Desktop.
Reindent the whole file
" Typing "++" reindents the whole file and restores the view (doesn't move the
" cursor or the viewport)
"
nnoremap ++ :call <SID>Reindent()<cr>
function! s:Reindent()
let saved_view = winsaveview()
normal! gg=G
call winrestview(saved_view)
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment