From b057f633efafcd99a02b66dac69395dea4d3102c Mon Sep 17 00:00:00 2001 From: dNItro Date: Wed, 20 Jan 2016 13:51:50 -0800 Subject: [PATCH 1/4] Add support to do transformation on multiple lines --- pythonx/UltiSnips/text_objects/_transformation.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pythonx/UltiSnips/text_objects/_transformation.py b/pythonx/UltiSnips/text_objects/_transformation.py index 2099213..7040e86 100644 --- a/pythonx/UltiSnips/text_objects/_transformation.py +++ b/pythonx/UltiSnips/text_objects/_transformation.py @@ -124,6 +124,8 @@ class TextObjectTransformation(object): self._match_this_many = 0 if 'i' in token.options: flags |= re.IGNORECASE + if 'm' in token.options: + flags |= re.MULTILINE if 'a' in token.options: self._convert_to_ascii = True From 8a8e183b805f499a22886d9d2e475c6a62aadf48 Mon Sep 17 00:00:00 2001 From: dNItro Date: Wed, 20 Jan 2016 13:54:38 -0800 Subject: [PATCH 2/4] Documentation on multiline option --- doc/UltiSnips.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/UltiSnips.txt b/doc/UltiSnips.txt index 3a80297..5a0ad6b 100644 --- a/doc/UltiSnips.txt +++ b/doc/UltiSnips.txt @@ -1235,6 +1235,10 @@ The options can be any combination of > i - case insensitive By default, regular expression matching is case sensitive. With this option, matching is done without regard to case. + m - multiline + By default, if you select multiple lines, transformations are made + on them entirely as a whole single line string. With this option you + can work with multi line strings. a - ascii conversion By default, transformation are made on the raw utf-8 string. With this option, matching is done on the corresponding ASCII string From 203218297c13725391d59c9ba046c8686a147e34 Mon Sep 17 00:00:00 2001 From: dNItro Date: Thu, 21 Jan 2016 03:28:19 -0800 Subject: [PATCH 3/4] More detailed documentation on multiline option --- doc/UltiSnips.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/doc/UltiSnips.txt b/doc/UltiSnips.txt index 5a0ad6b..b9b9ad9 100644 --- a/doc/UltiSnips.txt +++ b/doc/UltiSnips.txt @@ -1236,9 +1236,12 @@ The options can be any combination of > By default, regular expression matching is case sensitive. With this option, matching is done without regard to case. m - multiline - By default, if you select multiple lines, transformations are made - on them entirely as a whole single line string. With this option you - can work with multi line strings. + By default, the '^' and '$' special characters only apply to the + start and end of the entire string; so if you select multiple lines, + transformations are made on them entirely as a whole single line + string. With this option, '^' and '$' special characters match the + start or end of any line within a string ( separated by newline + character - '\n' ). a - ascii conversion By default, transformation are made on the raw utf-8 string. With this option, matching is done on the corresponding ASCII string From 4b27b7152dfbe121bc3d4aacc242099805b4cca7 Mon Sep 17 00:00:00 2001 From: dNItro Date: Mon, 25 Jan 2016 04:25:15 -0800 Subject: [PATCH 4/4] Testcase added! --- test/test_Transformation.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/test_Transformation.py b/test/test_Transformation.py index 9f7bfac..0b5ee20 100644 --- a/test/test_Transformation.py +++ b/test/test_Transformation.py @@ -179,6 +179,12 @@ class Transformation_OptionIgnoreCase_ECR(_VimTest): wanted = 'TEST blah' +class Transformation_OptionMultiline_ECR(_VimTest): + snippets = ('test', r"${VISUAL/^/* /mg}") + keys = 'test\ntest\ntest' + ESC + 'V2k' + EX + 'test' + EX + wanted = '* test\n* test\n* test' + + class Transformation_OptionReplaceGlobal_ECR(_VimTest): snippets = ('test', r"$1 ${1/, */-/g}") keys = 'test' + EX + 'a, nice, building'