Redir command

This commit is contained in:
ManjaroOne666 2018-11-27 21:57:06 +00:00
parent 02322f4214
commit e45df1e6c3
1 changed files with 31 additions and 3 deletions

34
vimrc
View File

@ -10,6 +10,8 @@ endif
if !has('nvim')
call plug#begin('~/.vim/bundle')
Plug '~/.config/vim/vim/bundle/vim-learnxiny'
" #ALE {{{
" https://github.com/w0rp/ale
Plug 'w0rp/ale'
@ -905,6 +907,30 @@ function! JsIncludeExpr(file)"{{{
endfunction
"}}}
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(<q-args>)
" 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
"}}}
"----------------------------------------------------------------------------}}}
@ -1075,13 +1101,17 @@ nnoremap <space>ee :e .<CR>
nnoremap <space>eq :Rex<CR>
"}}}
" better window/tab/buffer navigation/management {{{
" movement/navigation{{{
nnoremap <Esc>j :resize -5<CR>
nnoremap <Esc>k :resize +5<CR>
nnoremap <Esc>l :vertical resize +5<CR>
nnoremap <Esc>h :vertical resize -5<CR>
nnoremap <PageUp> :bprevious<CR>
nnoremap <PageDown> :bnext<CR>
" alias for :tjump <cword>
nnoremap <space>tj g<C-]>
" alias for @ptjump <cword>
nnoremap <space>tp <C-w>g}
"}}}
" location list and quickfix mappings {{{
@ -1583,7 +1613,5 @@ if exists('+showtabline')
endif " exists("+showtabline")
"----------------------------------------------------------------------------}}}
nnoremap <F11> :sp tags<CR>:%s/^\([^ :]*:\)\=\([^ ]*\).*/syntax keyword Tag \2/<CR>:wq! tags.vim<CR>/^<CR><F12>
nnoremap <F12> :so tags.vim<CR>
" vim: set foldmethod=marker: