From 20c3f3b5240ad522e5d88b3623e3ea7eae66dc24 Mon Sep 17 00:00:00 2001 From: Dmytro Meleshko Date: Thu, 3 Jun 2021 20:40:36 +0300 Subject: [PATCH] [nvim] redirect PutOutput into a preview window --- nvim/plugin/editing.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nvim/plugin/editing.vim b/nvim/plugin/editing.vim index f0af3ab..416d073 100644 --- a/nvim/plugin/editing.vim +++ b/nvim/plugin/editing.vim @@ -78,7 +78,13 @@ set commentstring=//%s nmap ] m'yygccp`'j nmap [ m'yygccP`'k - command! -nargs=+ -complete=command PutOutput execute 'put =execute(' . escape(string(), '|"') . ')' + function! PutOutput(cmd) + let output = execute(a:cmd) + execute "noswapfile pedit" "+" . fnameescape("setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile") fnameescape("preview://" . a:cmd) + wincmd P + call setline(1, split(output, "\n")) + endfunction + command! -nargs=+ -complete=command PutOutput silent call PutOutput() " ,c is easier to type than "+ because it doesn't require pressing Shift noremap c "+