Click link and paste new link
-
When you click a link and right click you can copy the link. Why can’t you paste a new link over it?
-
@2VNews ,
Why can’t you paste a new link over it?
Sometimes when I’m editing a file with links, I want to paste something into the URL; I would personally hate it if I could not paste into it, but instead it overwrote the whole link. And the way it is written, it is always possible to paste over a link – by first selecting the whole link – whereas if it were implemented the way you wanted, when I clicked in the middle and hit paste, if it defaulted to pasting over the link, there wouldn’t be a way to accomplish editing rather than overwriting a link using paste.
(This is just my opinion/interpretation.)
-
@PeterJones said in Click link and paste new link:
– by first selecting the whole link –
How do you do that? When the cursor is on a link I can right click and select “Copy link” but I don’t see “Select link” so that the OP could get what they desired by then pasting the replacement link content on top of the selected text, which is the link.
-
@mkupper said in Click link and paste new link:
How do you do that?
manually (use the mouse, use shift+arrow)
-
@PeterJones said in Click link and paste new link:
manually (use the mouse, use shift+arrow)
… but I do recognize how painful that could be, especially when you are in the middle of a long link with multiple path separators.
If there were a feature request submitted that requested a command be added to right click menu next to Copy Link, which would select the whole link (“Select Link”), I would upvote that feature request.
I would personally hate it if I could not paste into it
And thinking about it, I think I misunderstood the original request. I originally thought that the request was that if you were on a link, hitting Edit>Paste/
Ctrl+V
would paste overtop the whole link, which is what I would have “hated”. But if the original request was really asking that there be a new context-menu entry for “paste over active link”, similar to my “Select Link” suggestion, then I would upvote that feature request. Sorry for mis-understanding the original request and reacting too strongly. -
@PeterJones FYI, I looked at the code and the existing
Copy link
menu item will only appear if the current selection length is zero and and the cursor is within a link. If you select one or more characters within a link and then right-click the selection area thenCopy link
will not be available in the right-click menu.At present code that inserts
Copy link
into the menu dynamically replaces theCopy
item (IDM_EDIT_COPY) that’s in the right click contact menu withCopy link
(IDM_EDIT_COPY_LINK). The code that replaces a context menu item with a new one would now need to also add a new item to the list, presumably, below the item forCopy link
. I don’t know if adding context items on the fly is easy.I’ll post a feature request for adding
Select link
as it seems like something that won’t create too much astonishment.The “Select link” feature request is at https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14114
@2VNews seems to be asking for ‘Paste into link’ which is more challenging to add to the code and also creates decisions and possible astonishment or surprises. The decision is, would someone want Ctrl-V (paste) to automatically replace a link? If so, that’ll also need to be added to preferences. A related item is that ‘Paste into link’ will seem like clutter to many people. I suspect it should be turned off by default and enabled via config.xml and possible Preferences. Maybe it can be added as an Edit menu item and thus available for use by macros. Someone desiring to use “Paste into link” could either add a new keyboard shortcut or redefine the
Ctrl-V
shortcut if desired. A still tricky aspect is that “Paste into link” is usually only available if the selection size is zero and the cursor is within an underlined link.I did not add a feature request for this aspect pending further clarification of what is desired.
-
the right click menu should also contain paste over link, instead of just copy link.
-
@2VNews said in Click link and paste new link:
the right click menu should also contain paste over link, instead of just copy link.
I have added a comment about this on github.
https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14114#issuecomment-1711911031 -
Thanks mkupper
-
Thanks mkupper
-
This behavior is easy to write a script for, and as scripts can be configured to run from the editor’s right-click menu, a script solution seems to “check all the boxes”.
Here’s
UrlLinkSelectOrPasteover.py
:# -*- coding: utf-8 -*- from __future__ import print_function ######################################### # # UrlLinkSelectOrPasteover (ULSOP) # ######################################### # references: # https://community.notepad-plus-plus.org/topic/24893/click-link-and-paste-new-link # https://github.com/notepad-plus-plus/notepad-plus-plus/issues/14114 # for newbie info on PythonScripts, see https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript #------------------------------------------------------------------------------- from Npp import * #------------------------------------------------------------------------------- class ULSOP(object): def __init__(self): URL_INDIC = 8 curr_pos = editor.getCurrentPos() pasting = False if editor.indicatorValueAt(URL_INDIC, curr_pos): editor.setSel(editor.indicatorStart(URL_INDIC, curr_pos), editor.indicatorEnd(URL_INDIC, curr_pos)) if pasting: editor.paste() #------------------------------------------------------------------------------- if __name__ == '__main__': ULSOP()
If you want pasting behavior rather than selection behavior, change
pasting = False
topasting = True
. If you want both behaviors (in, say, two context menu entries), then you’ll need a second script (virtually a copy of the first). -