Since I am not a very experienced developer, it happened so that I came to the web recently - while writing code, I often have to refer to the official PHP and MySQL documentation, and also search for certain information while working with texts on a couple of sites not related IT, but related to my other work.
Notepad ++ and Internet Search
Previously, in case of a question, I needed to perform the following actions:
- Select a piece of text (or code);
- Copy it to the clipboard;
- Go to the browser;
- Paste the text from the clipboard into the search bar (where site: the site address or the requested site was already entered);
- Press the “search” (input) button.
With the help of the
NppExec add-
on, this can be done several times faster.
Of course, NppExec must be configured beforehand.
')
Install nppExec
Plugins-> Plugin Manager-> Show Plugin Manager-> NppExec-> Install. Restart Notepad ++.
Customization
Press F6.
In the Command (s) field, enter the following:
C:\...\chrome.exe php.net/manual-lookup.php?function="$(CURRENT_WORD)"&lang=ru
(instead of the ellipsis we insert the full path to the exe-file of the required browser).

Save: Save ... - php_search


Similarly, we set up a MySQL site search. Since I could not figure out the search on mysql.com - when I try to find something through the search bar on dev.mysql.com, for some reason, it redirects to search.oracle.com (and then the devil himself will break his leg) we search using Google:
Press F6.
"C:\...\chrome.exe" www.google.com/search?q="site:dev.mysql.com $(CURRENT_WORD)"
Save: Save ... - mysql_search.

Using
Now all you need to do is to select a phrase or word (for example, the name of a function) - Shift + Ctrl + rightArrow - and press Ctrl + F6. The browser will open on the required page and send a GET request with the selected word in the search bar (the first call to Ctrl + F6 is similar to F6 - you must enter or select a saved command, in our case - php_search or mysql_search).
In my example, I used the environment variable (environment variable, English environment variable) CURRENT_WORD, but the possibilities of complementing NppExec are much wider than just speeding up the search on the Internet. With the help of this plugin, you can run almost any external application and transfer them a wide range of variables - both your own and Windows system variables. This is described in detail in the
How to Run an external program from Notepad ++ article on sourceforge.net, the translation of which I present below.
How to run an external program from Notepad ++
Suppose you need to launch an external application (for example, a compiler, interpreter, or web browser) from Notepad ++ (menu item “Run”), passing the current document as an argument. To do this, you will have to use environment variables. The NppExec plugin provides more flexibility in this regard.
File Level Environment Variables
Using environment variable:
$(_)
For example, the current file you are editing in Notepad ++ is “E: \ my Web \ main \ welcome.html”.
Below are some environment variables containing information about the current session:
FULL_CURRENT_PATH - “E: \ my Web \ main \ welcome.html”.
CURRENT_DIRECTORY - "E: \ my Web \ main \".
FILE_NAME - “welcome.html”.
NAME_PART - “welcome”.
EXT_PART - "html".
SYS. <Variable> is the name of a system environment variable, for example, $ (SYS.PATH).
Variables should be framed with double quotes, since they can contain spaces:
"$(_)"
Examplesfirefox "$(FULL_CURRENT_PATH)"
iexplore "$(FULL_CURRENT_PATH)"
These two user commands are also included in Notepad ++ 3.0 and later versions. They can be launched by pressing Ctrl + Alt + Shift + X and Ctrl + Alt + Shift + I respectively.
Document Level Environment Variables
The following variables exist:
CURRENT_WORD - contains the word (s) currently highlighted in Notepad ++.
CURRENT_LINE - contains the line number of Notepad ++, on which the cursor is currently located.
CURRENT_COLUMN - contains the number of the column Notepad ++, on which the cursor is currently located.
NPP_DIRECTORY - contains the absolute path to the system directory Notepad ++.
Additional variables available with the NppExec plugin:
PLUGINS_CONFIG_DIR is the full path to the configuration directory where the plug-in files are located.
#N is the full path to the nth open document (n = 1, 2, 3 ...).
# 0 - The full path to the notepad ++. Exe file.
LEFT_VIEW_FILE - path to the file opened in the main (left) window of Notepad ++.
RIGHT_VIEW_FILE - path to the file opened in the additional (right) window Notepad ++.
If you know what directory the plugin is in, you can call any function of this plugin by passing the name of the plugin, the name of the function and, if required, the arguments to rundll.exe. Or unload the plugin with the regsvr / u command.
Exampleswww.php.net/%20$(CURRENT_WORD)
www.google.com/search?q=$(CURRENT_WORD)
en.wikipedia.org/wiki/Special:Search?search=$(CURRENT_WORD)
$(NPP_DIRECTORY)\notepad++.exe $(CURRENT_WORD)
In examples 1-3, we pass in the URL + argument as the currently selected word to the default browser in order to search for a word on the Internet.
The fourth example is useful if you want to open a file from the current document.
Suppose that we have a file containing the following entry:
include("../myFuncs.php");
If you select ../myFuncs.php and press the key combination to which you assign this command, then the file myFuncs.php opens in Notepad ++, if, of course, it exists and is located at the specified path.
The variable CURRENT_WORD allows you to conveniently configure external commands.
Running a command
When you use NppExec to run a command, the following variables are set and available for use before starting it:
CWD is the current working directory of NppExec (use “cd” to change it).
ARGC is the number of arguments passed to the NPP_EXEC command.
ARGV - all arguments passed to the NPP_EXEC command that follow the name of the script.
ARGV [0] - script name - the first parameter of the NPP_EXEC command.
ARGV [n] - the nth argument (1, 2, 3 ...)
RARGV - all arguments in reverse order (except for the script name).
RARGV [n] is the nth argument from the end (n, n-1, n-2, n-3 ...).
INPUT - this value is set by the 'inputbox' command.
INPUT [n] is the nth field of the $ (INPUT) variable.
If the external process "knows" about NppExec, then it can set some variables for use in NppExec (from version 0.3.1):
OUTPUT - this value can be specified by a child process (for more details, see the description of the npe_console v + command).
OUTPUT1 is the first line in $ (OUTPUT).
OUTPUTL is the last line in $ (OUTPUT).
It is necessary to add that the ability to quickly search google.com and en.wikipedia.org is built into Notepad ++ by default. It is necessary to select the necessary phrase and press Alt-F2 and Alt-F3 respectively.