Copy entire line without selecting it?
-
didn’t check when it has been added but the most recent versions do have it and
it is mapped to CTRL+SHIFT+X in default configuration.Check shortcut mapper, scintilla commands - the message you are looking for is
SCI_LINECOPY (row 92 for me).Cheers
Claudia -
I think a key point is that people expect this functionality on ctrl+c (or ctrl+x for “cut current line if no selection”)…they don’t want to have to remember a separate key combo for these special cases of copy/cut. Even when accepting of a separate keycombo, the default of ctrl+shift+x is horrible for the ‘copy’ variant, IMO.
-
Your Pythonscript also requires a separate keycombo for the functionality versus the normal copy function. Something like the following short script, mapped to ctrl+c (remove the default Scintilla ctrl+c assignment!), might be better as the user gets normal copy-selection capability plus (unselected) current line copy capability…without having to think about what they are doing (just hit ctrl+c!):
if len(editor.getSelText()) > 0: editor.copy() else: editor.copyText(editor.getCurLine()) -
CTRL+SHIFT+X copies the current line without having to select it.
You can find it in shortcut mapper - scintilla commands tab - SCI_LINECOPY
-
My similar question is "How to Delete entire current line (appearing multiline with word-wrap on) without selecting it first?
-
-
@Mikhail-V
@ScottSumnerWhy is the script any more complicated than this one line?
editor.copyAllowLine()
Replace the default Control-C mapped command with a pointer to that Pythonscript and that is all it takes. Unless I’m missing a key point… -
With 5 “likes” I guess I didn’t miss the point!
-
I’ve always liked the cutting/copying of entire lines like Visual Studio has (I’m sure many other editors/IDEs have it as well). There are at least 2 plugins available through the PluginManager that adds this functionality to N++. Myself, I’ve been using the following LuaScript for quite a while. I’m sure this logic could be easily adapted to be used in PythonScript as well:
-- Mimic Visual Studio's "Ctrl+C" that copies the entire line if nothing is selected npp.AddShortcut("Copy Allow Line", "Ctrl+C", function() editor:CopyAllowLine() end) -- Mimic Visual Studio's "Ctrl+X" that cuts the line if nothing is selected npp.AddShortcut("Cut Allow Line", "Ctrl+X", function() if editor.SelectionEmpty then editor:CopyAllowLine() editor:LineDelete() else editor:Cut() end end) -
Yes. Since the PythonScript “copy” case has already been beaten to death in this thread, but the PS “cut” case maybe hasn’t been, here’s the port of your LuaScript for that:
if editor.getSelectionEmpty(): editor.copyAllowLine() editor.lineDelete() else: editor.cut()A fairly direct port! :-D
Unfortunately, in PS shortcut-mapping isn’t as easy to do as it is in LS.
-
A Alan Kilborn referenced this topic on
-
I updated a script method for doing this HERE.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login