From 0fa604ccaefa2dd54bfbfc41a52bb61a60a53a60 Mon Sep 17 00:00:00 2001 From: Zheng Piaodan Date: Thu, 31 Dec 2020 23:36:44 +0800 Subject: [PATCH] fix: literal newline "\n" escape related to https://github.com/ruby-formatter/rufo-vim/issues/28 The echo command treats "\n" from selection as non-literal string, which causes one-line string like "hello\nworld" becoming two lines. Using `printf %s` preserves it as one line. --- autoload/rufo.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/rufo.vim b/autoload/rufo.vim index fe423a9..7ae871f 100644 --- a/autoload/rufo.vim +++ b/autoload/rufo.vim @@ -62,7 +62,7 @@ function! s:format(start_line, end_line) abort endif let l:selection = join(getline(a:start_line, a:end_line), "\n") - let l:out = systemlist('echo ' . shellescape(l:selection) . '| rufo') + let l:out = systemlist('printf %s ' . shellescape(l:selection) . '| rufo') return [s:formatting_failed(v:shell_error), l:out] endf