sponsor Vim development Vim logo Vim Book Ad

Decho : Vim script internal debugger (output in separate window, tab, or remote vim)

 script karma  Rating 126/44, Downloaded by 13340  Comments, bugs, improvements  Vim wiki

created by
Charles Campbell
 
script type
utility
 
description
The Decho.vim plugin provides debugging messages in a separate window.  One puts

    Decho "some message here"
-or-
    call Decho("another message")

and Decho will split the screen with a five line debugging window on the bottom of the display where the messages will appear.  Allows one to inspect multiple error messages with the usual vim editing commands!

To better support the debugging of scripts, Decho.vim also provides:

    call Dfunc("YourFunctionName([arg1<".a:arg1."> arg2<".a:arg2.">])")
    call Dret("YourFunctionName [returnvalue]")

These two functions use Decho(), but also provide function tracking.  The .vim/syntax/Decho.vim provides special highlighting for the DBG buffer, too.  See the example below!

One may redirect the output of arbitrary vim commands to the DBG buffer with the following function:

    call Dredir("command")

For example, consider

call Dredir("ls")

Decho.vim makes it easy to turn debugging on and off in your scripts:

    Turning Debugging On:
        vim yourscript.vim
        :DechoOn
        :wq

    Turning Debugging Off:
        vim yourscript.vim
        :DechoOff
        :wq

Some plugins use events such as WinEnter and others attempt to control window layout.  Decho supports these plugins with four methods to avoid disturbing the display:

DechoMsgOn  -- subsequent debugging output uses :echomsg
DechoRemOn  -- subsequent debugging output goes to a remote gvim which DechoRemOn will set up itself
        DechoTabOn  -- subsequent debugging output goes to a separate debugging tab/window
DechoVarOn  -- subsequent debugging output goes to a variable (default value: g:dechovar)

With any of these enabled, subsequent Dfunc, Dret, Decho, and Dredir output will be directed as indicated.

---------------------------------------------------------------------
Example:

    LocalBrowse(dirname<.>) {
    |NetGetcwd() {
    ||return NetGetcwd /home/cec/.vim/VIMSCRIPT/ }
    |dirname</home>
    |Perform directory listing...
    |bufnr(dirname</home>)=1
    |dirnamenr=1 dirname</home> pre-exists
    |changed directory to</home>
    |buffer already exists, but needs listing (buf#1)
    |Setting up local browser maps
    |NetGetcwd() {
    ||return NetGetcwd /home/cec/.vim/VIMSCRIPT/ }
    |NetGetcwd() {
    ||return NetGetcwd /home/cec/.vim/VIMSCRIPT/ }
    |NetGetcwd() {
    ||return NetGetcwd /home/cec/.vim/VIMSCRIPT/ }
    |NetGetcwd() {
    ||return NetGetcwd /home/cec/.vim/VIMSCRIPT/ }
    |NetGetcwd() {
    ||return NetGetcwd /home/cec/.vim/VIMSCRIPT/ }
    |NetGetcwd() {
    ||return NetGetcwd /home/cec/.vim/VIMSCRIPT/ }
    |set up banner
    |directories will be sorted by name
    |LocalBrowseList(dirname</home>) {
    |(elided for brevity)
    ||return LocalBrowseList }
    |SetSort() bannercnt=8 {
    |(elided for brevity)
    ||return SetSort }
    |NetSort() {
    ||return NetSort }
    |return LocalBrowse : file</home> }

(alpha/beta version available at http://mysite.verizon.net/astronaut/vim/index.html#DECHO)
 
install details
1. vim Decho.vba.gz
    :so %
    :q

2. This will create the following files:
  plugin/Decho.vim
  plugin/cecutil.vim
  syntax/Decho.vim
  doc/Decho.txt

(you may want the latest vimball handling script for this: vimscript#1502)
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
Decho.vba.gz 20 2008-10-23 7.0 Charles Campbell * DechoSep() can now be externally called (and :Dsep  makes it easy to use).  Creates an easy-to-find separator in the debugging output.
* bug fixes (Cyan, Magenta highlighting; improved DechoTab's tab search, unwanted DechoRemOn staircasing)
Decho.vba.gz 19 2007-05-10 7.0 Charles Campbell Various bugfixes and improvements...
Dredir now takes optional strings first instead of last.
The :Decho and :Dredir commands now take <args> instead of <q-args>, which allows them to act more like the function calls do.
DechoRemOn's remote vim no longer will have formatoptions' a or t suboptions set even if the user has specified something like fo+=at in his/her .vimrc.
If the user interposes a new tab (or deletes the "Decho Tab"), Decho finds the "Decho Tab" tab or creates a new one when called.
Decho.vba.gz 18 2006-09-05 7.0 Charles Campbell Decho now handles list arguments, works around ignorecase setting, and no longer uses bt=nofile (makes it easier to save).
Decho.tar.gz 17 2006-03-06 6.0 Charles Campbell The "Decho Tab" buffer now is syntax highlighted, plus bugfixes.
Decho.tar.gz 16 2006-02-27 6.0 Charles Campbell For vim 7.0 users: DechoTabOn/Off changed to reflect changes in vim 7.0's :tab, :tabn, :tabnew commands.  (Decho still works fine for vim 6.0, BTW)
Decho.tar.gz 15 2006-02-21 6.0 Charles Campbell Decho now supports use of vim7.0aa's "tab" feature -- with :DechoTabOn, subsequent debugging output goes to its own tab.
Decho.tar.gz 14 2006-02-15 6.0 Charles Campbell Decho has a new pair of commands: DechoRemOn and DechoRemOff.  With these, debugging output can be sent to a remote gvim.  Really helps with debugging plugins that use events and control window layout.
Decho.tar.gz 12 2005-11-22 6.0 Charles Campbell * DechoOn/Off now also turns on/off DechoVarOn/Off
* DechoMsgOn and DechoMsgOff installed; debugging messages will use the |echomsg| command.
* DechoVarOn and DechoVarOff installed; debugging messages will be appended to the variable specified by g:dechovarname, which by default is "g:dechovar".  These two commands toggle the variable "g:dechovar_enabled".
* Now includes a GetLatestVimScripts line for cecutil.vim
* Decho now does "runtime plugin/cecutil.vim" if that plugin hasn't been loaded yet.  It will also try the AsNeeded subdirectory if g:loaded_asneeded exists.
* with DechoMsgOn, Decho("doesn't") now works
* Dredir() now accepts multiple arguments (cmd and output)
Decho.tar.bz2 10 2004-08-03 6.0 Charles Campbell * New function: call Dredir("command") will redirect the command's output to the DBG buffer.
* Decho now uses keepjumps to avoid altering the jumplist table (requires vim6.3)
* Decho's appending to the DBG buffer no longer flags it as modified.
* One may have Decho ignore BufEnter events if g:decho_bufenter exists.
Decho.tar.bz2 8 2004-06-07 6.0 Charles Campbell Decho now has :Dhide and :Dshow commands for toggling the visibility of the DBG buffer
Decho.tar.bz2 7 2004-06-02 6.0 Charles Campbell With g:decho_hide=1, Decho will keep its DBG buffer hidden, thereby allowing window-manipulating scripts their natural behavior.  Use :ls! to see the DBG buffer, and you may use :b [nmbr] to see it.
In additon, Decho's DBG window's is silently created, and Dfunc/Decho/Dret will always resize the DBG window to the number of lines specified by g:decho_winheight.
Decho.tar.bz2 6 2004-05-11 6.0 Charles Campbell Now, along with Decho(), is
  Dfunc("funcname(...)") -- for tracking entry to function funcname
  Dret("funcname ...") -- for tracking return from function funcname
Includes special syntax highlighting for Dfunc/Decho/Dret files, too.
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github