When I select text in Notepad++ and then copy ^c and paste ^v, I lose the selection.
Is there a way to paste but keep the pasted text selected?
Pasting without losing selection
- littlegandhi1199
- Posts: 195
- Joined: 29 Aug 2016, 23:58
Re: Pasting without losing selection
I'm sure this tip will come in handy. A core windows function exists which lets you tab through words in a line
Holding Ctrl+Left and right will go through the text as it finds spaces/enumerators (which it thinks are important)
Holding Ctrl+Shift+Left will go through (while also selecting them). It might be useful to you!
Here's a script that counts spaces in clipboard then issues correct number to go back to highlight your paste
after sending it.
Now to take it a step further we'll have to figure out the behavior it gets up to when it finds commas and % signs in there
Here's the script that works with clipboard pastes that only have spaces in them
Code: Select all
Clipboard =
(
The dog jumped over the sleeping cat
)
msgbox, Loaded your clipboard test a paste`n`n"%Clipboard%"
^V::
SendInput, +{Ins}
If (Paste = 1)
{
loop, parse, Clipboard, %A_Space%
Total := A_Index
SendInput, ^+{Left %Total%}
}
Else
{
Paste = 1
msgbox, Now try it again with new pasting
}
return
Script Backups on every Execution
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155
Scrabble Solver 4-15 letter word outputs (
# of inputs)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285
![Mr. Green :mrgreen:](./images/smilies/icon_mrgreen.gif)
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155
Scrabble Solver 4-15 letter word outputs (
![Crazy :crazy:](./images/smilies/icon_crazy.gif)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285
Re: Pasting without losing selection
Not really the best method but it does work
Copy your text like normal and then paste it with ctrl+v
When you release the ctrl key,it will mark all of the rows
It does similar thing as littlegandhi1199 example but in a faster way
Copy your text like normal and then paste it with ctrl+v
When you release the ctrl key,it will mark all of the rows
Code: Select all
#IfWinActive,AHK_class Notepad++
~^v::
KeyWait,Ctrl
Count =
Loop,Parse,Clipboard,`n
Count += 1
Send,{Shift Down}
Send,{Up %Count%}
Send,{Right}
Send,{Shift Up}
Return
- littlegandhi1199
- Posts: 195
- Joined: 29 Aug 2016, 23:58
Re: Pasting without losing selection
Oh yeah multiple lines.
So I started with that approach too but it wouldn't work if you were only pasting to the end of a line.
That would go back and select the entire line.
***However if that is sufficient and you'll only be pasting to blank lines (and not adding to the end sometimes) then that would work no matter what characters were contained in it and you could call it a day with his code.
If you will be posting to the end of lines then give me a day and I'll figure out how it works and get back to you
>>>There's mine (now supporting multiple lines) but still only spaces. Took out the tutorial to shorten it down lol
So I started with that approach too but it wouldn't work if you were only pasting to the end of a line.
That would go back and select the entire line.
***However if that is sufficient and you'll only be pasting to blank lines (and not adding to the end sometimes) then that would work no matter what characters were contained in it and you could call it a day with his code.
If you will be posting to the end of lines then give me a day and I'll figure out how it works and get back to you
>>>There's mine (now supporting multiple lines) but still only spaces. Took out the tutorial to shorten it down lol
Code: Select all
^V::
SendInput, +{Ins}
loop, parse, Clipboard, %A_Space%
Total := A_Index
loop, parse, Clipboard, `n`r
{
If (A_Index > 1)
Total++
}
SendInput, ^+{Left %Total%}
return
Script Backups on every Execution
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155
Scrabble Solver 4-15 letter word outputs (
# of inputs)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285
![Mr. Green :mrgreen:](./images/smilies/icon_mrgreen.gif)
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155
Scrabble Solver 4-15 letter word outputs (
![Crazy :crazy:](./images/smilies/icon_crazy.gif)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285
Re: Pasting without losing selection
Yes, unfortunately it only supports spaces and not other delimiters that ctrl-left stops at, like / or .littlegandhi1199 wrote: ↑28 Apr 2020, 21:51>>>There's mine (now supporting multiple lines) but still only spaces. Took out the tutorial to shorten it down lol
It also doesn't handle leading spaces and tabs.
The fool-proof way (handles even Unicode) is to not use CTRL-LEFT but simply LEFT
Code: Select all
moveback := StrLen(clipboard)
SendInput, +{Ins} ; paste clipboard
SendInput, +{Left %moveback%}
return
There must be a better way to paste without losing selection...
![Confused :?](./images/smilies/icon_e_confused.gif)
Re: Pasting without losing selection
Notepadd++ actually have an option to mark a selection
This kinda work...most of the time
This kinda work...most of the time
Code: Select all
~^c::
KeyWait,c
WinMenuSelectItem,A,,Edit,Begin/End Select
Return
~^v::
KeyWait,v
WinMenuSelectItem,A,,Edit,Begin/End Select
Return
Re: Pasting without losing selection
Doesn't work if the menu bar is hiddenvsub wrote: ↑01 May 2020, 13:21This kinda work...most of the timeCode: Select all
~^c:: WinMenuSelectItem,A,,Edit,Begin/End Select
![Sad :(](./images/smilies/icon_e_sad.gif)
Could it be done via Scintilla Control somehow?
I found https www.scintilla.org /ScintillaDoc.html#SelectionAndInformation. Broken Link for safety Could AHK use Scintilla directly to paste without losing the selection?
Re: Pasting without losing selection
What about this
Code: Select all
^v::
MouseMove, A_CaretX, A_CaretY, 0
click down
Send, ^v
MouseMove, A_CaretX, A_CaretY, 0
click up
return
Re: Pasting without losing selection
Try Ctrl+D
Cheers.
![Wink ;)](./images/smilies/icon_e_wink.gif)
Cheers.
Re: Pasting without losing selection
Your code doesn't work for me. Also I guess it would fail when the pasted text is long and scrolls the the screen.GEV wrote: What about thisCode: Select all
^v:: MouseMove, A_CaretX, A_CaretY, 0...
Re: Pasting without losing selection
This seems to be working here but it requires the Menu to be visible(unless you map a hotkey to the "Begin/End Select" from Settings=>Shortcut Mapper and then replace WinMenuSelectItem with the hotkey but with WinMenuSelectItem is more likely to work properly)
Select a text with the mouse and then paste it with ctrl+v
Select a text with the mouse and then paste it with ctrl+v
Code: Select all
SetWinDelay,-1
#IfWinActive,AHK_class Notepad++
~LButton::
MouseGetPoS,,,,Control
IfNotInstring,Control,Scintilla
Return
StatusBarGetText,Line,3,A
Line := SubStr(Line,6,InStr(Line,A_Space,,1,2))
StringReplace,Line,Line,% A_Space,,All
KeyWait,LButton
StatusBarGetText,Line1,3,A
Line1 := SubStr(Line1,6,InStr(Line1,A_Space,,1,2))
StringReplace,Line1,Line1,% A_Space,,All
If (Line > Line1)
{
Start := Line1
End := Line
}
Else
{
Start := Line
End := Line1
}
Return
~^v::
KeyWait,Ctrl
Sleep,100
StatusBarGetText,Line1,3,A
Line1 := SubStr(Line1,6,InStr(Line1,A_Space,,1,2))
StringReplace,Line1,Line1,% A_Space,,All
If (Line1 != End)
End := Line1
WinMenuSelectItem,AHK_class Notepad++,,Search,Go To
WinWaitActive,Go To...
ControlSetText,Edit1,% Start,A
Send,{Enter}
WinWaitClose,Go To...
WinMenuSelectItem,AHK_class Notepad++,,Edit,Begin/End Select
Sleep,50
WinMenuSelectItem,AHK_class Notepad++,,Search,Go To
WinWaitActive,Go To...
ControlSetText,Edit1,% End,A
Send,{Enter}
WinWaitClose,Go To...
WinMenuSelectItem,AHK_class Notepad++,,Edit,Begin/End Select
Return
Re: Pasting without losing selection
I've added now a shortcut to Notepad++. Thank you for that tip. Now everything works.
Interestingly, sometimes clipboards do get messed up when I use SendInput, ^v, but when I use Send, ^v it always works.
Who is online
Users browsing this forum: Google [Bot], Tech Stuff, Vanda_a and 373 guests