Welcome to NppTags documentation!

Introduction

NppTags is a Universal Ctags plug-in for Notepad++.

When you use Notepad++ to program in a popular programming language (like C, C++, Java, JavaScript, PHP), ctags can be very useful for you. It creates a so called tags file that can be used to navigate through your sources. This plug-in can help you to jump to a selected function / variable / class / etc in your code by pressing just one key!

History

There are several ctags based plug-ins for Notepad++, but none of them really fits my needs. There are to limited (only jump, just one file, based upon line numbers, etc) or to slow at startup. Back in 2002 and 2003 I wrote an add-on for TextPad named FindTag. I used this code base to create my own ctags based plug-in for Notepad++.

How to install

To manually install the plug-in, in the plugins directory in the Notepad++ installation directory, create a folder named NppTags and place NppTags.dll and ctags.exe in that directory. Then (re)start Notepad++.

Provided ctags executable

In the zip is a precompiled version of ctags.exe. This is always a recent version of the Windows executables provided by the Universal Ctags project when the plugin was released.

You can always try to replace the provided version of ctags.exe with a more recent version.

Note that is you are upgrading from an older build of ctags you may have to put your local ctags.cnf or .ctags file to a file in the .ctags.d directory. See the Files section in the documentation of ctags for more details.

How to use this plug-in

To use this plug-in you first need to generate a tags database in the directory of the current source file by pressing the Generate button in the toolbar. This will first generate a tags file, using the ctags program, which is converted to a SQLite database directly after that. This tags database is used by the plug-in.

Basic use

This plug-in has different ways to use:

  • Jump to Tag tries to find the tag (function, variable, etc) under the cursor. If you want to jump to this tag simply press the assigned button (default Alt+Q) or the button in the toolbar. If there is only one reference found, you will be taken to it. Otherwise a dialog is shown where you can select the right one.
  • The tree shows all (recognized) tags in a tree. You can double-click on a tag in the tree and you will be taken to it.
  • Jump Back (default Ctrl+Alt+Q) will bring you back to the position where you were when you jumped to a tag.

Source files in a directory tree

Make sure you generate the database from the root directory of your project, that means with a file in that directory active. When you have generated the database and you open a file in a sub-directory NppTags will first look in the current directory for the tags database. If it cannot find one, it will go up a number of times to see if a database can be found there.

Do not try to generate a tags database from the root directory (like C:\) of your harddisk. Because of the ctags -R flag it will search your entire disk for source files, which is probably not what you want.

When you need to regenerate your existing database you can just click the button on the toolbar. The plug-in will know where the database is located.

Tree

Since ctags supports so many programming languages, it is impossible for me to add proper support for all these languages to the tree instantly.

There is a generic treebuilder that tries builds a basic tree for every language. For some languages there is a specific treebuilder that tries to build a tree as good as it can, although they are not perfect at this moment.

These languages have a specific treebuilder:

  • C / C++
  • C#
  • Java
  • reStructuredText
  • SQL

If your programming language isn’t in the list and/or the tags for your programming language don’t show (properly) in the tree, contact me because it is probably not too difficult to add or improve support for other languages and/or types.

Note that this it only affects the tree, Jump to Tag shouldn’t have any problem. If Jump to Tag does not work as expected, contact me as well.

Options

The Options dialog lets you control some of the behavior of the plug-in. It can be found in Plugins, NppTags, Options....

Here you have these options:

Maximum depth is the number of directories the plug-in will go up to search for the tags database.

Jump Back Stack is the size of the stack of locations used by Jump Back.

Path to ctags.exe specifies the location of ctags.exe. When left empty, the plug-in will search for ctags.exe as described in the installation instructions.

NppTags.ini

The options are stored in an ini-file that is normally found in your “Application Data” directory and is named NppTags.ini. On my Windows 10 machine this directory is C:\Users\Frank\AppData\Roaming\Notepad++\plugins\config.

These are the default settings:

[Options]
Show=1
Depth=3
JumpBackStack=4
CtagsPath=

Show is controlled by the Show Tags Tree button on the toolbar and stores if the tree is shown.

The other options correspond to the various items in the dialog.

Debug section in NppTags.ini

For debugging it can be necessary to see the raw tags file or see what ctags is exactly doing. You can manually add an extra section with read-only options to the NppTags.ini to control what happens to the automatically generated tags file. These are the default settings:

[Debug]
DelTags=1
OverwriteTags=1
CtagsVerbose=0

When DelTags is set to 0 the plug-in will not delete the generated tags file after it is converted to the database.

When OverwriteTags is set to 0 and a tags file is found the plug-in will not overwrite and regenerate this existing tags file before generating the database. When set to 0, this implies that DelTags is set to 0 as well. Can be useful when regenerating the database but you don’t want to execute ctags every time.

When CtagsVerbose is set to 1 the --verbose flag is added when ctags is executed. The output is written to tags.stdout and tags.stderr.

Frequently Asked Questions

Q: Does NppTags recognize tags in language XYZ?

A: NppTags relies on Universal Ctags for the recognition of tags. So please check the documentation of Universal Ctags to see if your language is supported by Universal Ctags. If not, you have to contact the Universal Ctags team to see if they want to add support for your programming language. If Universal Ctags supports your language Jump to Tag should have no problems, but the tree could not show any or all tags.

Q: I want to ignore some files when ctags generates the tags file. Can I add extra command line options?

A: If you want to add extra command line options to ctags, create a file .ctags.d/exclude.ctags. Add lines with the --exclude= command line options you need.

It can be placed in the current directory for local settings or in your user directory for global settings. See the Files section in the documentation of ctags for more details.

Q: Why are the languages C and C++ are displayed as ‘C/C++’?

A: This is done because .h files are standard marked as C++ by ctags. And for tags there is not too much difference between C and C++ to not combine them.

Q: When I jump to a tag it misses it by a few lines or it can not find it at all.

A: You probably need to regenerate the tags database by pressing generate button. Another problem may be that there is no unique search pattern for this tag. An option to use line numbers instead of seach patterns is planned.

Wish list

  • Show the tags per file. This should be configurable per language, and maybe even per language, per database.
  • Building better trees for many languages.
  • Internally always use WCHARS for filenames
  • Add an option to set a path to a secondary tags database. If the tag is not found in the default tags database, the secondary one should be searched. Such a tags database can be created from the root of your programming environment to search the standard libraries. Where to find this secondary database could be based upon the language of current document, or a tags database option.
  • Nest enums and structs in C++ classes in the tree.
  • Auto-completion based upon the tags database.
  • Options per tags database. Preserve those settings when the database is regenerated.
  • Optional set the hidden attribute for tags.sqlite.
  • Option to use line numbers instead of search patterns. Note that adding -n to a .ctags.d/*.ctags file already gives you this result.
  • Make the plug-in multi-threading, especially when generating the tags file and converting that to the database.
  • When Jump to Tag is used and there is no database, ask to generate it and then jump to the tag.
  • Expand the tree item of a generic language if there is only one type.
  • Add a searchbox above the tree.

Known Issues

General

  • When you double-click in the tree the focus will not return to the edit window. I use the code from NppSnippets where it just works, but here is doesn’t work. The context menu item Jump to Tag does work as expected.
  • Switching between files leaves the tree untouched when there is no tags database found for the new source file.
  • Find out how to use the full search pattern to jump to the line, while searching. So including the ^ and $ to ensure the entire line is searched for.
  • Recent versions of Universal Ctags have changed ho to behave on long JavaScript and CSS files. This is most visible on minimized files. The current check in NppTags to prevent items from minimized files to show up on the tree need to be updated.

TreeBuilder specific

  • The C# treebuilder shows a class twice per namespace when this class is split over two files, for instance in a situation of a partial class defined in both FrmMain.cs and FrmMain.Designer.cs. I need a come up with a decent solution for this. What should be the tag to jump to when the class name is selected?
  • The C# treebuilder does not recognize nested namespaces yet.

How to compile

To compile NppTags you can use Visual Studio. Project files for VS 2019 are provided and actively used. To compile with other versions of Visual Studio you can convert the existing project files.

There is also a MinGW-w64 Makefile, using their 32-bit compilers. It can be used from Cygwin and MSYS2. The debug build of this makefile is not tested with gdb.

Contact

The plug-in’s web page can be found at https://github.com/ffes/npptags.

If you have problems with, questions about or suggestions for NppTags please use GitHub. This is by far the best way to contact me. Pull requests are much appreciated! If for some reason you want to contact me directly, you can send me an email at fesevur@gmail.com.

License

This plug-in is published under the GPL-2 license. See GNU General Public License for the full license agreement. You can find the sources of the latest version and the current developments at GitHub.

This plug-in relies on Universal Ctags to recognize the tags. Universal Ctags is released under GPL-2 as well and the source code of Universal Ctags can be found at GitHub.

Changelog

Version 0.9.1, 2021-04-11

  • Provide a 64-bit version of the plugin.
  • Adjust to the new plugins directory of Notepad++.
  • Setting CtagsPath was not saved.
  • Remove the changelog from the About dialog. It is already in the documentation.
  • Add menu entry to put the focus on the tree. This makes the plugin more keyboard friendly.
  • Allow Enter-key to be used to go to a tag from the tree.
  • Include latest git commit SHA in About dialog.
  • Upgrade to libreadtags 0.1.0
  • Upgrade to SQLite 3.35.4

Version 0.9.0, 2015-12-05

  • The color of the tree match the selected Notepad++ theme.
  • Add an Options dialog.
  • Rewrite of the way the language trees are built.
  • Add a Java, reStructuredText and SQL tree.
  • Add an option to specify the path to ctags.exe
  • Converted DocBook documentation to reStructedText and publish it at Read the Docs.
  • Add Jump Back to bring you back to the position where you were when you jumped to a tag.
  • Better support for sources stored in sub-directories.
  • Very simple Tags Properties MessageBox.
  • Add debug option to store the output of ctags --verbose.
  • Updated to recent Universal Ctags build.
  • Upgrade to SQLite version 3.9.2.

Version 0.2.0, 2013-11-23

  • After generating the tags file, it is now converted to a SQLite database. This makes it much easier and faster to build a proper tree.
  • Tree filled with common types of tags for various languages. Still far from perfect.
  • In the Select Tag dialog, preselect the first tag in the current file.
  • Show a separate root item per language, if more then one language is found.
  • Using a SVN (rev 804) based build of ctags.exe for better JavaScript support and two personal patches.
  • Upgrade to SQLite version 3.8.1

Version 0.1.1, 2013-07-05

  • Tree now filled with functions.
  • Added three toolbar buttons.

Version 0.1.0, 2013-06-30

  • Internal proof of concept

GNU General Public License

Preamble

The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software - to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation’s software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too.

When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.

To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it.

For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.

We protect your rights with two steps:

  1. copyright the software, and
  2. offer you this license which gives you legal permission to copy, distribute and/or modify the software.

Also, for each author’s protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors’ reputations.

Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone’s free use or not licensed at all.

The precise terms and conditions for copying, distribution and modification follow.

TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

Section 0

This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The “Program”, below, refers to any such program or work, and a “work based on the Program” means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term “modification”.) Each licensee is addressed as “you”.

Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.

Section 1

You may copy and distribute verbatim copies of the Program’s source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program.

You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee.

Section 2

You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions:

  1. You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change.
  2. You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License.
  3. If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: If the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.)

These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it.

Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program.

In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License.

Section 3

You may copy and distribute the Program (or a work based on it, under Section 2 in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following:

  1. Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
  2. Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or,
  3. Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.)

The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable.

If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.

Section 4

You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

Section 5

You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it.

Section 6

Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients’ exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License.

Section 7

If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program.

If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances.

It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice.

This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License.

Section 8

If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License.

Section 9

The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and “any later version”, you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation.

Section 10

If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally.

NO WARRANTY Section 11

BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

Section 12

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

END OF TERMS AND CONDITIONS

Indices and tables