Is there a shortcut, plugin or code to wrap text with quotation marks (""
or ''
) in Notepad++?
Eg "text"
.
I don't know Python and other advanced programming languages, so please explain in a simple way ...
Is there a shortcut, plugin or code to wrap text with quotation marks (""
or ''
) in Notepad++?
Eg "text"
.
I don't know Python and other advanced programming languages, so please explain in a simple way ...
I know this is kind of old but I stumbled upon this while searching for an answer to an unrelated problem so maybe other people will too. Here's an improvement to nichos' answer: Instead of two regexes this can easily be done with just one
Search for ^(.+)$
Replace with "\1"
I'm not sure if you want the whole line or just each word. This will do each line:
Open replace (ctrl H)
Find: ^.
Replace with: "
make sure you select "regular expression" in the search mode.
Select replace all.
That will add a " at the start of each non-blank link.
For the ending one:
Find: .$
Replace with: "
Wrapping a selected text
Plugins
-> Python Script
-> New Script
qquote
(say)in opened Npp doc insert this code:
class qquote01:
qq='"'
editor.replaceSel(qq+editor.getSelText()+qq)
Attention on indentation (it is PYTHON ...), Save
.
Plugins
-> Python Script
-> Configuration
... search the qquote.py
, select it.Add
. This is required because we need the name of that script appeared in plugins menu.Settings
-> Shortcut Mapper
and look at the top of the frame for Plugin commands
button, click it, then search the qquote
name, assign shortcut. Plugins
-> Python Script
-> item qquote
exist and the script has a designated shortcut.qq
, if you wish, on any character or sequence of characters.You can use regular expressions for this.
Find:
(([a-zA-Z]+):)
Replace with:
("\2"):
To create the new macro functions:
Open the file shortcuts.xml you find in Notepad++ directory
Into "macro" section add the following code:
<Macro name="Selection Into Double Quotes" Ctrl="yes" Alt="yes" Shift="no" Key="50">
<Action type="0" message="2177" wParam="0" lParam="0" sParam="" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam='"' />
<Action type="0" message="2179" wParam="0" lParam="0" sParam="" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam='"' />
</Macro>
<Macro name="Selection Into Single Quotes" Ctrl="yes" Alt="yes" Shift="no" Key="49">
<Action type="0" message="2177" wParam="0" lParam="0" sParam="" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="'" />
<Action type="0" message="2179" wParam="0" lParam="0" sParam="" />
<Action type="1" message="2170" wParam="0" lParam="0" sParam="'" />
</Macro>
Save, close, the file, restart N++: You will find the new functions into "Macro" Menu.
To use it: Simply select the text and choose the desired menu item or use the desired keyboard shortcut showed at the right side of the menu item itself.
Just few days ago I got aware that there is a plugin that can be installed using Plugin Admin that can do exactly what is asked by the OP:
Surrounds the selection in single|double quotes/brackets/parenthesis/etc.
The plugin name is SurroundSelection. I installed it on Npp 853 and it seems to work as expected. How to use it: Install it and activate it from its own menu, than select the target text, and on the keyboard press the button of the symbol you want to use to wrap the selection into, for example, the parenthesis.
As far as I discovered until now it works well with
and maybe with others I did not discover yet.
I find it much better than my previous solution using Npp macros.