From 1dbe682f99d170236ca9b04ae68c9a082ab80d60 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Mon, 5 Jul 2021 10:30:24 +0800 Subject: update --- vimrc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'vimrc') diff --git a/vimrc b/vimrc index a9ef222..fe19803 100644 --- a/vimrc +++ b/vimrc @@ -107,6 +107,31 @@ autocmd FileType json setlocal foldmethod=syntax " Apply new SniptMat Parser let g:snipMate = { 'snippet_version' : 1 } +" Redirection with buffer +" Usage: +" :Redir hi ............. show the full output of command ':hi' in a scratch window +" :Redir !ls -al ........ show the full output of command ':!ls -al' in a scratch window +function! Redir(cmd) + for win in range(1, winnr('$')) + if getwinvar(win, 'scratch') + execute win . 'windo close' + endif + endfor + if a:cmd =~ '^!' + let output = system(matchstr(a:cmd, '^!\zs.*')) + else + redir => output + execute a:cmd + redir END + endif + vnew + let w:scratch = 1 + setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile + call setline(1, split(output, "\n")) +endfunction + +command! -nargs=1 -complete=command Redir silent call Redir() + """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Settings for Vimwiki """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -- cgit v1.2.3-70-g09d2