Using Understand with an external editor – SlickEdit

We know that sometimes you’ve used an editor for so long that there is no way you could leave it. For that reason, Understand allows you to run with any external editor. One of our customers asked about SlickEdit today, so that’s what I am going to show, but the same steps apply for any other editor.

 

image

The first step is to setup Understand to call the external editor instead of its own. The option is under Tools |  External Editor Settings …

image

Click the checkbox, then navigate to the editor executable. The next part will depend on the command line settings for your application, but essentially you launch the editor with the filename, line number, and column number. Here are the settings I used for SlickEdit:

image

This will cause all files Understand uses to be opened in SlickEdit instead of Understand, allowing you to use it as your editor. The cursor also jumps to the correct part of the file and selects the text of the object that was referenced. I like this setup best with dual monitors, but it works fine with one:

image

 

The next step allows you to access the Understand context menu from inside of SlickEdit. This gives you all of the Understand features inside your favorite editor.

You can open the context menu for a location inside of a file using the following:

understand.exe -existing -contextmenu FILENAME -line LINENUMBER -col COLUMNNUMBER -text ENTITYTEXT

While Understand provides this capability, this can still be a little tricky since you have to know how to customize your editor. I spent several hours trying to figure this out since I haven’t ever used the SlickEdit customization before. My thanks to H2 for helping my figure this out. If you find a better way to do this, please let me know (support@scitools.com).

To do this we will create a custom Macro script named undCMenu.

Open a new file in SlickEdit and paste the following.


_command void undCMenu () name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_REQUIRES_MDI_EDITORCTL)
{
_GetBufferContents(mytext)
_str cmdline="understand.exe -existing -contextmenu " :+ maybe_quote_filename( p_buf_name ) :+
       " -line " :+p_line :+ " -col " :+ p_col :+ " -text " :+ cur_word(junk,'',1);
//concur_command (cmdline,0,1);
external_command(cmdline);
}

Save the file as und.e and hit F12 to load it. Once it’s loaded as a macro you can do several things. You can set a hotkey for the menu by using Tools | Options | Keyboards | Key Bindings. I actually bound mine to the middle mouse button so I can access it very fast.

And/or you can add it as a menu option in Macro | Menus – I’d suggest adding it to _ext_menu_default

image

Then whenever you use the hotkey or right click on anything in SlickEdit, you have easy access to the Understand Menus and features. The best of both Worlds!