diff --git a/rc/detection/modeline.kak b/rc/detection/modeline.kak index a2c5fef7..6e067b1a 100644 --- a/rc/detection/modeline.kak +++ b/rc/detection/modeline.kak @@ -114,9 +114,10 @@ define-command -hidden modeline-parse-impl %{ # [text]{white}{vi:|vim:|ex:}[white]{options} # [text]{white}{vi:|vim:|Vim:|ex:}[white]se[t] {options}:[text] define-command modeline-parse -docstring "Read and interpret vi-format modelines at the beginning/end of the buffer" %{ - try %{ evaluate-commands -draft %{ - execute-keys "s(?S)\A(.+\n){,%opt{modelines}}|(.+\n){,%opt{modelines}}\z" \ - s^\S*?\s+?\w+:\s?[^\n]+ x + try %{ evaluate-commands -draft -save-regs ^ %{ + execute-keys -save-regs "" gk %opt{modelines} JK x Z + execute-keys gj %opt{modelines} KJ x a + execute-keys s^\S*?\s+?\w+:\s?[^\n]+ x evaluate-commands -draft -itersel modeline-parse-impl } } }