Delete commenting prefix on empty lines in Python
This commit is contained in:
parent
019fbc5439
commit
cea35cf5f4
|
@ -163,13 +163,26 @@ add-highlighter shared/python/code/ regex ^\h*(?:from|import)\h+(\S+) 1:module
|
||||||
# Commands
|
# Commands
|
||||||
# ‾‾‾‾‾‾‾‾
|
# ‾‾‾‾‾‾‾‾
|
||||||
|
|
||||||
define-command -hidden python-insert-on-new-line %{
|
define-command -hidden python-insert-on-new-line %{ evaluate-commands -itersel -draft %{
|
||||||
evaluate-commands -draft -itersel %{
|
execute-keys <semicolon>
|
||||||
# copy '#' comment prefix and following white spaces
|
try %{
|
||||||
try %{ execute-keys -draft k x s ^\h*#\h* <ret> y jgh P }
|
evaluate-commands -draft -save-regs '/"' %{
|
||||||
|
# copy the commenting prefix
|
||||||
|
execute-keys -save-regs '' k x1s^\h*(#+\h*)<ret> y
|
||||||
|
try %{
|
||||||
|
# if the previous comment isn't empty, create a new one
|
||||||
|
execute-keys x<a-K>^\h*#+\h*$<ret> jxs^\h*<ret>P
|
||||||
|
} catch %{
|
||||||
|
# if there is no text in the previous comment, remove it completely
|
||||||
|
execute-keys d
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# trim trailing whitespace on the previous line
|
||||||
|
try %{ execute-keys -draft k x s\h+$<ret> d }
|
||||||
|
}
|
||||||
|
} }
|
||||||
|
|
||||||
define-command -hidden python-indent-on-new-line %<
|
define-command -hidden python-indent-on-new-line %<
|
||||||
evaluate-commands -draft -itersel %<
|
evaluate-commands -draft -itersel %<
|
||||||
# preserve previous line indent
|
# preserve previous line indent
|
||||||
|
|
Loading…
Reference in New Issue
Block a user