Customize Toolbar Plugin and 'Duplicate Current Line' plugin
Notepad++ 7.5.9 32-bit
Plugin Manager 184.108.40.206
Customize Toolbar 4.2
I’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.
Edit->Line Operations->Duplicate Current Lineonly uses the line number where the cursor is currently located as reference (same
LN: xxnumber 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).
Meta Chuh last edited by
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_SELECTIONDUPLICATEat the shortcut mapper (default value)
it does not trigger the scintilla command
SCI_LINEDUPLICATEas it should.
(see screenshot below)
also the menu
edit > line operation > duplicate current linedoes not display the shortcut mapped to
SCI_LINEDUPLICATEas it is supposed to, but it shows the shortcut mapped to
SCI_SELECTIONDUPLICATE. this can create confusion.
i’m still trying to figure out, if it is possible to run
SCI_SELECTIONDUPLICATEfrom 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.
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.
guy038 last edited by guy038
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 + Dshortcut of N++, whereas the
Edit > Line Operations > Duplicate Current Linejust duplicates current line, regardless of a possible selection !
But, why you don’t simply use the
Ctrl + Dshortcut ? 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 command
View > 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 Marginicon and the
View > Hide Line Number Margincommand work properly, you must check the
Display line numberoption, in the Settings > Preferences… > Editing tab ;-))
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 to
macro > start recording
ctrl+dto duplicate your selection at the test file
macro > stop recording
macro > save current recorded macroand save it as
Duplicate Current Selection(without setting any keyboard shortcut)
now open your custom button config file,
CustomizeToolbar.btn, usually located at:
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.