Move selection horizontally
-
Hi,
is there an existing shortcut/Macro/LuaScript for moving a selection horizontally?
I excessively use [ctrl]+[shift]+[up] and +[down] to move whole lines, now I search for an option to move a selection left and right, like VS Code and Atom do (https://github.com/microsoft/vscode/issues/5251). -
@cennoxx said in Move selection horizontally:
is there an existing shortcut/Macro/LuaScript for moving a selection horizontally?
Aren’t you talking about Ctrl-X and Ctrl-V, cut and paste. These are standard Windows commands, and generally work across all applications.
Terry
-
@terry-r No, I want to move the selection one character left (or right) at the time, without clicking three different shortcuts. The image at https://github.com/microsoft/vscode/issues/5251 shows it good.
-
@cennoxx ,
Notepad++ has the ability to move the selected line up or down (Edit > Line Operations > Move Up/Down Current Line). But, that I know of, it doesn’t currently have any commands for “move current selected text right/left”. But I have been known to not know or remember certain features of Notepad++ (it can do a lot, and I am always surprised at things I didn’t know about it that others bring up in answers here!), so others will chime in if they know of a feature that I didn’t think of.
Notepad++ uses a library from another developer for handling most of the low-level text editing stuff… but maybe if you followed the directions in our Feature Request FAQ, you could see if the Notepad++ developers can add that… and if not, maybe they or you could ask the library developer to add the feature, so that Notepad++ would get it in the next update of that library.
Also, it’s possible that it could be scripted – if you were willing to install a plugin like PythonScript, you could try to write the script yourself, or you might find one of the regulars here interested enough to figure it out for you… though at least before I’d think about it in detail and see if I could come up with something, I’d want to know that you were willing to go down that path.
-
@peterjones Thank you for the detailed reply. Since it looks like this functionality doesn’t exist yet, I’ll see if I can write a script using Scintilla commands…
-
If anyone is interested, I made a LuaScript doing this, it’s not perfect, but for me it works for now.
-- Move selection one character left npp.AddShortcut("Selection Add Each", "Alt+,", function() if not(editor.SelectionEmpty) then local selText = editor:GetSelText() editor:BeginUndoAction() editor:DeleteBack() editor:CharLeft() editor:AddText(selText) editor:SetSel(editor.CurrentPos, editor.CurrentPos-string.len(selText)) editor:EndUndoAction() end end) -- Move selection one word left npp.AddShortcut("Selection Add Each", "Alt+Shift+,", function() if not(editor.SelectionEmpty) then local selText = editor:GetSelText() editor:BeginUndoAction() editor:DeleteBack() editor:WordLeft() editor:AddText(selText) editor:SetSel(editor.CurrentPos, editor.CurrentPos-string.len(selText)) editor:EndUndoAction() end end) -- Move selection one character right npp.AddShortcut("Selection Add Each", "Alt+.", function() if not(editor.SelectionEmpty) then local selText = editor:GetSelText() editor:BeginUndoAction() editor:Clear() editor:CharRight() editor:AddText(selText) editor:SetSel(editor.CurrentPos, editor.CurrentPos-string.len(selText)) editor:EndUndoAction() end end) -- Move selection one word right npp.AddShortcut("Selection Add Each", "Alt+Shift+.", function() if not(editor.SelectionEmpty) then local selText = editor:GetSelText() editor:BeginUndoAction() editor:Clear() editor:WordRight() editor:AddText(selText) editor:SetSel(editor.CurrentPos, editor.CurrentPos-string.len(selText)) editor:EndUndoAction() end end)
-
@cennoxx
If you block select using Alt+Shift+Arrow keys, you can afterwords drag the selection using the left mouse.