Created
January 11, 2015 20:32
-
-
Save fmoralesc/4a971691b29c64921ea5 to your computer and use it in GitHub Desktop.
indentuntil
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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