Skip to content

Instantly share code, notes, and snippets.

@chrismcg
Created March 27, 2010 11:34
Show Gist options
  • Save chrismcg/345965 to your computer and use it in GitHub Desktop.
Save chrismcg/345965 to your computer and use it in GitHub Desktop.
" select at current indent level from http://vim.wikia.com/wiki/Visual_selection_of_indent_block
" modified for ruby to allow selecting the prev and next lines too for blocks
function! SelectIndent (blockmode)
let temp_var=indent(line("."))
while indent(line(".")-1) >= temp_var
exe "normal k"
endwhile
if a:blockmode == "yes"
exe "normal k"
end
exe "normal V"
while indent(line(".")+1) >= temp_var
exe "normal j"
endwhile
if a:blockmode == "yes"
exe "normal j"
end
endfun
nmap gb :call SelectIndent("yes")<CR>
nmap gn :call SelectIndent("no")<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment