In the process of program development, one of the functions that programmers often use is to find references (find Reference), and the corresponding function inside Visual Studio is "Find All references" (Find all References).
When I wrote the code using notepad++, I was plagued by the fact that I couldn't find a similar function. Have to find all references every time you use Find in files.
However, each lookup requires traversing the entire file system of the target directory, which can take a long time to file.
notepad++ has plug-ins that implement the ability to find references. Instead of searching the entire file system, this plug-in only needs to do a keyword index once, and then just look it up in the keyword index. The speed is fast and the result is instantaneous. And even if you modify the file later, you do not need to regenerate the keyword index database, because the keyword index database is automatically updated when the file is saved.
This plugin is nppgtags. The default parser for Nppgtags is for the source files of C, C + +, YACC, Java, PHP4, and assembler only, but changing the configuration slightly can support Lua, Python, or other types of language.
Under the Nppgtags directory (depending on your notepad++ installation directory, mine is C:\Program Files (x86) \notepad++\plugins\ NPPGTAGS) has a file gtags.conf has a file gtags.conf
This specifies that a different parser file (DLL) is used for different languages when using a non-default parser. I found that when using the parser of build-in, I specified a different language corresponding to the file suffix name! So I guess the addition of. Lua can support the creation of the keyword index database for LUA files. As shown below:
Next (make sure to cut back the default parser in setting, not pygments or ctags. If you do not change the setting then it must be the default parser, do not need to switch. ), then click on the plugin->nppgtags->create database to create the index databases, and then select the keywords to find references (click on the plugin->nppgtags->find Reference), The results are as shown (find results in the bottom-most window, here is a reference to "rect"):
It is convenient to use with shortcut keys. I generally set the shortcut key to find reference ctrl+shift+g, select the keyword and press the shortcut key to get the results of the lookup reference. Double-click from the Find results to access the source file corresponding to the location to view the changes.
Positioning the cursor on a word (no need to check) can also make a lookup reference to the word, if you want to find a reference to a keyword, but do not know which file the keyword appears in, just want to position the cursor at any non-word place (such as empty line, or a parenthesis end of the place, etc.), Then the lookup reference (shortcut key or menu entry), there will be a window to find references, there will be a keyword code hint function.
Similarly, other languages only need to add the suffix name of the corresponding source file in the same way gtags.conf can use the lookup reference (for example, only needs to join in the gtags.conf appropriate location.). py supports lookup references to Python files. Yes, it's cool, isn't it:D
--------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Here are some attempts to find out how to handle non-C C + + files (I'm trying lua files here), just to record:
This is said in the official statement of the plugin: Gtags built-in code parser supports C, C + +, YACC, Java, PHP4 and Assembly. Other languages is supported through Pygments + CTags parser. This means that the default (built-in) parser only supports C C + + YACC Java PHP4 and assembly language, while optional pygments and CT AGS Parser These two parsers are available for support in other languages. I use notepad++ to develop LUA scripts, so it seems that only the latter two parsers are selected. But Ctags parser actually can only use find definitions and find Reference (find reference) This function is useless. Pygments This has not been used successfully, prompting "Gtags:cannot open shared object ' Pygments-parser.dll '.
It is frustrating to find that LUA cannot be supported. But then I tried. Change the. Lua suffix name to. C To use! So I thought about it. Rename the. Lua under the project file to. C or. hpp to support Lua lookup references. I've actually written a script to do this, so I can find all the references, but it's still necessary to run it. Lua. If you copy a copy and modify the copied. Lua to. C or. HPP, it is not possible to make the modification at the same time as the perfect support for the lookup reference, because the modification will need to apply the corresponding modification to the file with the suffix name modified, and the click Jump in the lookup reference cannot jump to the. lua file, so it cannot be Make modifications to the corresponding LUA files.
Finally in the search pygments can not be used (because someone on the web said to jump out of the hint that Pygments-parser.dll is not open because the path is not correct) found in the process of modifying the gtags.conf file to achieve the purpose we want. :)
Another plug-in of the same type is called "Gtags Search" in Plugin manager, and is called "Gtagfornplus" after installation. However, after a trial, I found that it was not available in the current version of notepad++ (6.7.9.2). Method of use See: http://sourceforge.net/p/gtagfornplus/code/HEAD/tree/
notepad++ Find references (find Reference) (for C C + + and various scripts such as LUA, Python, etc.)