Skip to content

Instantly share code, notes, and snippets.

@fmoralesc
Created January 11, 2015 20:32
Show Gist options
  • Save fmoralesc/4a971691b29c64921ea5 to your computer and use it in GitHub Desktop.
Save fmoralesc/4a971691b29c64921ea5 to your computer and use it in GitHub Desktop.
indentuntil
function! g:IndentUntil()
let c = getchar()
let indent = stridx(getline(line('.')-1), nr2char(c))
if indent > 0
let c_indent = indent-indent('.')
if c_indent > 0
exe "normal 0i\<space>\<esc>".(c_indent-1)."."
else
let dedent = abs(c_indent)
exe 'substitute/^\s\{'.dedent.'}//'
endif
endif
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment