Customize Toolbar Plugin and 'Duplicate Current Line' plugin
-
Notepad++ 7.5.9 32-bit
Plugin Manager 1.4.12.0
Customize Toolbar 4.2I’m not entirely sure if this is related to the plugin or not.
When I use Edit->Line Operations->Duplicate Current Line (a.k.a. ctrl-D) on selected text, it duplicates what I’ve selected, which is what I like.
If I use the Duplicate Current Line button that I put on the toolbar with the Customize Toolbar Plugin, it ignores text that I highlighted and instead only duplicates the line the cursor is on.
Can the Duplicate Current Line button be made to work with selected text the same way as Edit->Line Operations->Duplicate Current Line?
-
this is a normal behaviour.
it behaves the same if used either from the menu or from a customised toolbar.the function
Edit->Line Operations->Duplicate Current Line
only uses the line number where the cursor is currently located as reference (sameLN: xx
number you see in your status bar at the bottom).there is no need to select any text, as it will not use your selection, but the cursor position at the end of your selection, and it will always duplicate one single entire line.
possible explanation for your case: if you coincidentally have selected a complete line with it’s line feed, then the cursor will be at the beginning of the next line, below the line you have selected, so using “duplicate current line” will now duplicate the line below your selected (marked) line.
if you want to duplicate a text selection, which can also contain more than one line, then you could, for example, use copy/paste (ctrl-c/ctrl-v).
-
side note:
the above was tested today on:notepad++ 7.6.3 32-bit
plugins admin (built in)
customize toolbar 4.2 -
I used the Chrome extension Screencastify to capture this video. I’ve never used Screencastify before but did so in order to demonstrate the issue. You can apparently use the same extension to view it, but I’ve also successfully downloaded the video file and played it with VLC media player so you don’t need Chrome or the extension to view it.
I could have sworn that Edit->Line Operations->Duplicate Current Line did what I described, but now it seems to just be control-d. I was wrong. Edit->Line Operations->Duplicate Current Line and the customized toolbar button do work the same, but I would like them to work like the control-d keyboard shortcut assigned to Edit->Line Operations->Duplicate Current Line.
You can see in the video that control-d works as I described: it uses the selection and doesn’t act on just a single line.
One advantage I like to using control-d is that I don’t lose what is currently in the clipboard.
How do I get Edit->Line Operations->Duplicate Current Line to work like the shortcut key (control-d) that it is assigned to?
(Sorry that this ended up being in the Plugin Development cateogory.)
-
thanks for your video, it loads fine and explains everything.
yes, you are correct.
this is a little notepad++ bug (a quite funny one) and here are my test results:-
ctrl+d is set to the scintilla command
SCI_SELECTIONDUPLICATE
at the shortcut mapper (default value)
it does not trigger the scintilla commandSCI_LINEDUPLICATE
as it should.
(see screenshot below) -
also the menu
edit > line operation > duplicate current line
does not display the shortcut mapped toSCI_LINEDUPLICATE
as it is supposed to, but it shows the shortcut mapped toSCI_SELECTIONDUPLICATE
. this can create confusion.
i’m still trying to figure out, if it is possible to run
SCI_SELECTIONDUPLICATE
from a custom toolbar button (as a workaround), so that you can use that button for SCI_SELECTIONDUPLICATE instead of ctrl+d.btw: if you want to file this issue to the developers, please read and follow the community guide for bug reports: >>> FAQ Desk: Feature Request or Bug Report <<< to submit a notepad++ issue at github.
-
-
my apologies, i forgot to link the “link” from above: >>> FAQ Desk: Feature Request or Bug Report <<<
it’s like sending an email and forgetting the attachment (-‸ლ)
-
Thanks, @Meta-Chuh, happy to create a bug report for this – issue#5298. I zipped the recording and attached the actual file to the github issue because I don’t know how long I’ll keep it on my Google Drive.
-
Hi @Meta-Chuh,
I’ve been searching for a couple of hours for the workaround idea you had, but can’t find a way to link SCI_SELECTIONDUPLICATE to a button. If you find a way, I’d be grateful.
-
Hello, @taa1 and All,
I admit that it would be nice to find out a way to create a button, which simulates the true behavior of the
Ctrl + D
shortcut of N++, whereas theEdit > Line Operations > Duplicate Current Line
just duplicates current line, regardless of a possible selection !But, why you don’t simply use the
Ctrl + D
shortcut ? It quite faster than clicking on any button, anyway ;-))
Personally, I prefer to put, in the toolbar, some icons like, for instance,
Hide Line Number Margin
. Indeed, the menu commandView > Hide Line Number Margin
( added by the installation of the Customize ToolBar plugin ) cannot be mapped to a shortcut ! Hence, the interest of having an icon ;-))Remark : In order that the
Hide Line Number Margin
icon and theView > Hide Line Number Margin
command work properly, you must check theDisplay line number
option, in the Settings > Preferences… > Editing tab ;-))Best Regards,
guy038
-
But, why you don’t simply use the Ctrl + D shortcut ? It quite faster than clicking on any button, anyway ;-))
👍
i think @taa1 thinks the same about that, as we do.
i guess its just: “i don’t need it at all, but now that i’ve found this bug, i somehow i just want it” 😂😉
i’ve found a workaround using the built in macro function, together with customized toolbar.
-
first open or create any text file for testing, and select any amount of text
then go tomacro > start recording
now pressctrl+d
to duplicate your selection at the test file
go tomacro > stop recording
go tomacro > save current recorded macro
and save it asDuplicate Current Selection
(without setting any keyboard shortcut) -
now open your custom button config file,
CustomizeToolbar.btn
, usually located at:%AppData%\Notepad++\plugins\Config\CustomizeToolbar.btn
-
add this line at the position you like:
Macro,Duplicate Current Selection,,,optional_icon.bmp
it should look like the screenshot below
then save CustomizeToolbar.btn -
now restart notepad++ and … tadaaa … here is the button 😃
note: you can also execute SCI_SELECTIONDUPLICATE using powerful scripting plugins like pythonscript, but for ctrl+d alone, the macro workaround will be the simplest solution.
-