"Goto File" by Selection

From EditPlus Wiki
Revision as of 12:46, 27 March 2005 by Wmjordan (Talk | contribs) (Usage)

Jump to: navigation, search

In some programming languages which allows "include" or "import", you might reference several files in a file, and sometimes, you will need to open the referenced file while you editing the main file. You may wish to open the file in a easier fashion without navigating through several folders in the "Directory" window.

Purpose

Let's take a look at an example:

You have opened a file "C:\web\webpage\sample.html", and a line in that file looks like that:

<script language="javascript" src="../script/client.js"></script>

So, the location of the "client.js" is "C:\web\script\client.js". You highlight (select) the string "../script/client.js" in that line, and wish to open the file immediately, without navigating to the "C:\web\script" folder.

Solution

Here's the trick:

  1. Open the "Preferences" dialog
  2. Configure your Editplus to run in Single Instance mode (in the General category of the dialog, UNCHECK the "Allow multiple instances").
  3. Add a new User Tool in the "Tools/User Tools" section of the "Preferences" dialog.
    1. Menu text: "Goto File" (or something else you like)
    2. Command: the location of your EditPlus, for example, mine is "D:\Projects\EditPlus\editplus.exe" (WITHOUT quotation marks)
    3. Argument: "$(CurSel)" (WITH quotation marks)
    4. Initial directory: $(FileDir)
    5. Uncheck all checkboxes below
  4. Press "OK" to close the "Preferences" dialog.
  5. Try it. When you want to open a file by text selection, use the tool that we created just now.

Usage

  1. Open a file that references other files
  2. Select (highlight) the refenrece string, such as "../script/client.js" (WITHOUT quotation marks)
  3. Hit the tool "Goto File"
  4. EditPlus should open the file, located relative to the currently opened file, if it exists.


This trick is originally provided by W. Jordan