diff --git a/UltiSnips/python.snippets b/UltiSnips/python.snippets index 31e2f51..b7d780b 100644 --- a/UltiSnips/python.snippets +++ b/UltiSnips/python.snippets @@ -29,7 +29,7 @@ ts = '\t' if vim.eval("&expandtab") == 1: ts = " " * int(vim.eval("&ts")) -indent = initial_indent + ts * 2 +indent = ind + ts * 2 args = [arg.split('=')[0].strip() for arg in t[4].split(',') if arg] args = [arg for arg in args if arg and arg != "self"] @@ -64,7 +64,7 @@ args = [arg for arg in args if arg and arg != "self"] if args: res += '\n' -indent = initial_indent + ts +indent = ind + ts for arg in args: res += indent + ":%s: description\n" % arg ` diff --git a/doc/UltiSnips.txt b/doc/UltiSnips.txt index 9d6e47c..6d4e554 100644 --- a/doc/UltiSnips.txt +++ b/doc/UltiSnips.txt @@ -271,6 +271,7 @@ can be used: > t - The values of the placeholders, t[1] -> current text of ${1} and so on cur - The current text of the placeholder. You can check if this is != "" to make sure that the interpolation is only done once + ind - The indentation text appearing before the first line of the snippet Also, the vim, re, os, string and random modules are already imported inside the snippet code. This allows for very flexible snippets. For example, the diff --git a/plugin/UltiSnips/TextObjects.py b/plugin/UltiSnips/TextObjects.py index 3b725fa..9657204 100644 --- a/plugin/UltiSnips/TextObjects.py +++ b/plugin/UltiSnips/TextObjects.py @@ -728,7 +728,7 @@ class PythonCode(TextObject): 'path': path, 'cur': ct, 'res': ct, - 'initial_indent': self._indent + 'ind': self._indent } exec self._code in d