How to disable duplicate line?
-
Occasionally there is an error in my code because somehow I’m duplicating a line without realizing it. I’ve gone looking through the Settings menu 🡺 Shortcut Mapper… and used the filter to look for the word duplicate and found nothing. I’ve also searched here on the forums, Duck Duck Go and Google and they all give me non-related results. I have version 8.7.5 installed.
-
From the main menu,
Edit->Line Operations->Remove Consecutive Duplicate Lines
andEdit->Line Operations->Remove Duplicate Lines
. Documentation here.FWIW, these commands may not do what you want, because they will delete ALL duplicate lines, and you may well have lines that are supposed to be duplicated (for example, close curly braces denoting the end of a code block). If you wanted to find duplicate lines, that is a job for regular expressions.
-
@jabcreations Do you mean the
Ctrl+D
keyboard shortcut which normally maps to Edit / Line Operations / Duplicate Current Line?It’s in the shortcut mapper in the Scintilla commands tab and is SCI_SELECTIONDUPLICATE
When filtering is used in the shortcut mapper it only shows you matches in the current tab. If you were seeking something such as the the word
duplicate
then you need to flip though the tabs, one at a time, within the shortcut mapper.Apparently, because it’s a Scintilla shortcut, the
Ctrl-D
shortcut does not show as a hint when you look at Edit / Line operations in the menus. It also does not show up in the shortcut mapper when you look in the main menu section. That seems like a bug to me but hopefully someone else will chime in with an explanation of the logic behind that. -
@Mark-Olson No.
The very title of this thread is how to disable duplicate lines not remove duplicate lines. I was exceptionally clear about disabling the keyboard shortcut.
-
I searched each tab one-at-a-time originally as you suggested in reply.
The SCI_SELECTIONDUPLICATE setting does exist and none of the keyboard options are set/checked however it clearly was still happening.
-
Hello, @jabcreations, @mark-olson, @mkupper and All,
-
You must first run
Settings > Shortcut Mapper... >
-
Then, select the
Scintilla Command
tab -
And, finally, filter, for example, by the word
selection
Best Regards,
guy038
-
-
Can you post your Debug Info here?
-
@jabcreations Besides the debug info that @Alan-Kilborn asked for I’m wondering about a couple of things:
By “disable duplicate line?” are you asking how to disable or remove the keyboard shortcut for duplicating lines or are you asking about how to make
Edit / Line Operations / Duplicate Current Line
disappear from the menu structure?I assume that since it’s happening accidentally that you are asking about finding and getting rid of the keyboard shortcut.
What happens when you do
Ctrl+D
which is the default keyboard sequence mapped to duplicate line?-
Specifically, open any file in Notepad++.
-
Make sure the icon in the left side of the tab for the current file is normal and not the red that happens when there are unsaved changes.
-
Do
Ctrl+D
-
If the icon did not change to red then we know that
Ctrl+D
is mapped to do something that does not make changes to the file and that we still don’t know why you are seeing duplicated lines at times. Don’t bother with the steps below but instead, let us know thatCtrl+D
seemed to do nothing at all. -
If the tab icon changed red then it’s a clue that
Ctrl+D
made some change to the file and we now need to figure out what happened. -
Did
Ctrl+D
duplicate the current line or did it seem to do nothing? If you are working with a 100% blank file it may be hard to detect line duplication and so I’d type some stuff and then do aCtrl+D
again to see if the stuff is duplicated. -
Did
Ctrl+D
turn the icon red but seemed to do nothing even though you didCtrl+D
on a line with stuff on it? I would enableView / Show Symbol / Show Control Characters & Unicode EOL
. If that was turned off then you are probably now looking at the lettersEOT
in white with a black background. That means theCtrl+D
is not mapped to anything and that you are adding anEOT
character to the file each time you typeCtrl+D
.
None of this will tell us exactly why lines are getting duplicated but will hopefully point the way to discovering why.
-
-
Notepad++ v8.7.5 (64-bit)
Build time : Dec 21 2024 - 05:13:03
Path : C:\MEDIA\OFFICE\Notepad++\notepad++.exe
Command Line : “D:\My Documents\Desktop\Tasks\Hack Attack Stuff\Attack Log.txt”
Admin mode : ON
Local Conf mode : OFF
Cloud Config : OFF
Periodic Backup : ON
Placeholders : OFF
DirectWrite : OFF
Multi-instance Mode : monoInst
File Status Auto-Detection : cdEnabledNew (for current file/tab only)
Dark Mode : OFF
OS Name : Windows 10 Pro (64-bit)
OS Version : 22H2
OS Build : 19045.3930
Current ANSI codepage : 1252
Plugins :
DSpellCheck (1.5)
mimeTools (3.1)
NppConverter (4.6)
NppExport (0.4)
_CustomizeToolbar (5.3) -