Vim Tips Wiki

Editing

Capture ex command output

1
  • The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit. If you are undoing an edit that is …
Latest revision Your text
Line 31: Line 31:
 
silent execute a:cmd
 
silent execute a:cmd
 
redir END
 
redir END
if empty(message)
+
tabnew
echoerr "no output"
+
silent put=message
else
+
set nomodified
" use "new" instead of "tabnew" below if you prefer split windows instead of tabs
 
tabnew
 
setlocal buftype=nofile bufhidden=wipe noswapfile nobuflisted nomodified
 
silent put=message
 
endif
 
 
endfunction
 
endfunction
 
command! -nargs=+ -complete=command TabMessage call TabMessage(<q-args>)
 
command! -nargs=+ -complete=command TabMessage call TabMessage(<q-args>)
Line 88: Line 88:
 
command! -nargs=+ -complete=command Output call OutputSplitWindow(<f-args>)
 
command! -nargs=+ -complete=command Output call OutputSplitWindow(<f-args>)
 
Example: :Output echo strftime("%H:%M")
 
Example: :Output echo strftime("%H:%M")
:I think I incorporated the useful stuff out of this script into the tip. I did not see much in the way of important differences, and in some ways the tip was better. --[[User:Fritzophrenic|Fritzophrenic]] ([[User talk:Fritzophrenic|talk]]) 18:00, June 3, 2015 (UTC)
 
 
----
 
----
  Loading editor
Below are some commonly used wiki markup codes. Simply click on what you want to use and it will appear in the edit box above.

View this template