javascript navigation



  • Are there any plugins that allow me to easily navigate around a set of js files? At the moment if I want to find where something is defined I have to use Find In Files, which is a little slow. I’m wondering if there might be a plugin that helps.

    And are there any other javascript plugins that I should know about? I have found JSTool which is good for formatting and other things. But is there anything else?

    Thanks.



  • @Robert-Ulph said in javascript navigation:

    And are there any other javascript plugins that I should know about?

    Not necessarily a Javascript-specific plugin, but you could look at the ‘tags’ plugins that use ctags.

    I use (a modified version of) TagLEET. There is also NppGTags which I’ve tried and works OK - I just prefer the TagLEET interface. Both are available from the “Plugin Admin” and both have 32- and 64-bit versions.

    TagLEET requires you to create a tags file in the root of your project’s directory. I forget if NppGTags does it automatically or if you need to create as well. As you code and add new functions, you’ll need to periodically re-run the tag generation (usually just ctags -R) from the root of your project’s directory.

    Cheers.



  • Thanks.

    This looks like quite a lot of complication for what I would have imagined to be quite simple. For instance this. Maybe I’ll find time to get used to it.

    My alternative when working on an issue is just to write down on a piece of paper the line numbers of the functions that are relevant and look at those to navigate around.



  • @Robert-Ulph said in javascript navigation:

    This looks like quite a lot of complication

    Not that hard.

    1. Install ctags
    2. Make sure it’s in your PATH
    3. create a config file for common options (here’s a subset of what I use):
      C:\Users\YOUR_USERNAME\.ctags
    --c-kinds=+cdefglmnpstuvx
    --c++-kinds=+cdefglmnpstuvx
    --extra=fq
    --fields=+n
    --file-scope=yes
    
    --regex-perl=/^[ \t]*?use[ \t]+([^; ]+).*;/\1/u,use,uses/
    --regex-perl=/[ \t]*?my[ \t]+[$@%]([^; ]+).*;/\1/v,variable,variables/
    
    1. Set a shortcut key in N++ for Plugins => TagLEET => Lookup Tag. I use “Alt+Enter”

    cd YOUR_PROJECT_DIRECTORY
    ctags -R
    

    Steps 1-4 are one-time setup. For new projects, you just need to do step 5 and enjoy ctags navigation magic!

    Cheers.



  • It seems that if you use the formatting tool with JSTool you have to be careful to select the code you want it to apply to. Otherwise it does it to the whole document, and messes up any html as well as php code and converts the file type (bottom left of notepad++) to javascript, which you don’t want if you have a php file.



    1. What PATH?

    I can just bookmark lines in Notepad++, which is very easy, although it doesn’t navigate across documents.



  • @Robert-Ulph said in javascript navigation:

    …bookmark lines…which is very easy, although it doesn’t navigate across documents.

    Is there a missing feature in Notepad++, to quickly show all bookmarked lines across all documents?
    Something that could write its output to the Find result window maybe?
    Like a Find in All Open Docs where the search target, instead of being text, is merely the bookmark status on a line?
    Seems like a natural feature evolution!



  • @Robert-Ulph said in javascript navigation:

    What PATH?

    Your Windows PATH environment variable:

    cmd.exe

    echo %PATH%

    Just put ctags.exe in a directory that’s in that path. Or add a directory where you install ctags to your PATH:

    Control Panel => System => Advanced System Settings => Environment Variables

    0434fc85-5f6b-48cd-8e2e-21d14cc8cc71-image.png

    Cheers.



  • @Michael-Vincent said in javascript navigation:

    Your Windows PATH environment variable

    Perhaps showing my advanced age, but I never thought we’d get to the point where THAT had to be explained. :-)
    Nice job doing it.
    If we ever need a FAQ entry on it, that could be the model.


Log in to reply