Skip to content

Instantly share code, notes, and snippets.

@hokaccha
Created August 25, 2009 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hokaccha/174687 to your computer and use it in GitHub Desktop.
Save hokaccha/174687 to your computer and use it in GitHub Desktop.
function! VisualCurrentIndentBlock()
let current_indent = indent('.')
let current_line = line('.')
let current_col = col('.')
let last_line = line('$')
let start_line = current_line
while start_line != 1 && current_indent == indent(start_line - 1)
let start_line = start_line - 1
endwhile
let end_line = current_line
while end_line != last_line && current_indent == indent(end_line + 1)
let end_line = end_line + 1
endwhile
call cursor(start_line, current_col)
normal V
call cursor(end_line, current_col)
endfunction
nnoremap gi :call VisualCurrentIndentBlock()<CR>
onoremap gi :normal gi<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment