Skip to content

Commit 7c8e00e

Browse files
committed
intelligent dedenting, thx @unpingco (closes #15)
before this patch <M-s> in visual mode would just remove the indentation from all of the selected lines. With this, it removes the indentation level of the first line in the selection, so that further indentation is preserved, but this block does not produce indentation errors when sent to IPython.
1 parent 33edf32 commit 7c8e00e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ftplugin/python/ipy.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,10 @@ def dedent_run_this_line():
350350
vim.command("silent undo")
351351

352352
def dedent_run_these_lines():
353-
vim.command("'<,'>left")
353+
r = vim.current.range
354+
shiftwidth = vim.eval('&shiftwidth')
355+
count = int(vim.eval('indent(%d+1)/%s' % (r.start,shiftwidth)))
356+
vim.command("'<,'>" + "<"*count)
354357
run_these_lines()
355358
vim.command("silent undo")
356359

0 commit comments

Comments
 (0)