In Using Understand with an external editor – SlickEdit we explain how to hook up Understand to run with SlickEdit. As a follow up, here are the commands to setup the same Understand menu inside of EMACS, Visual Studio, and Vi. Do let us know if we made any mistakes here since we’re not experts on these editors.


EMACS

Add the following lisp to your .emacs file to open the Understand right click menu when C-c u is pressed (thanks for the correction Guillaume):

Note: this assumes the understand executable is in your path


(defun understand-word-at-point ()
"Run understand menu for the word at point."
(interactive)
(setq understand-command
(concat
"understand -existing -contextmenu " (buffer-file-name)
"-text "(current-word)" -line "
(number-to-string (count-lines (point-min) (point)))
" -col " (number-to-string (current-column))
) )
(shell-command understand-command)
)
(global-set-key "C-cu" 'understand-word-at-point)


Visual Studio

Step 1: Add Understand to Visual Studio’s External Tools


  • On the Tools menu, click External Tools
  • Click Add
  • Type “&Understand Menu” in the Title box
  • Type “C:Program FilesSTIbinpc-win32understand.exe” in the Command box
  • Type “-existing -contextmenu $(TargetPath) -line $(CurLine) -col $(CurCol) -name $(CurText) in the Arguments box
  • Click OK


Step 2: Add a keyboard shortcut to Visual Studio


  • On the Tools menu, Click Options
  • Expand the Environment Folder and select Keyboard
  • Type “Tools.ExternalCommand” in the box labeled “Show commands containing”
  • Select the ExternalCommand associated with the “&Understand Menu” External Tool. If “&Understand Menu” was 8th on the list (default) then select Tools.ExternalCommand8
  • Click the box labeled “Press shortcut key(s)”. Type in a keyboard combination such as Ctrl+U or Ctrl+`
  • Click Assign
  • Click Ok


Vi

Add the following to your vi startup file -.vimrc, _vimrc, etc. Note: this assumes the understand executable is in your path:


Linux/Unix: (courtesy of Devin)


:command! UMenu silent: exe “!understand -existing -contextmenu %: p -line ” line(‘.’) ” -col ” col(‘.’) ” -text &” | redraw!
map :UMenu


Windows: (thanks for the help Ilguiz):


command UMenu silent: exe join([‘!understand -existing -contextmenu “$(cygpath -w “%:p”)” -line ‘, line(‘.’), ‘ -col ‘, col(‘.’), ‘ -text ‘, ‘’, ‘ &’]) | redraw!
map :UMenu