I'm using neovim v0.8.0 (nightly build) on Arch Linux.

When in my plugins.lua where I have all my nvim plugins listed, I want to be able to use gX to open user/repo in my browser as https://github.com/user/repo.

Since the plugins are not listed as full URLs, I can't use the normal gx. I know they're always wrapped in single quotes so I can put them in the clip board with "+yi'. However, I don't know a way to put the copied text in an cmdline-mode command after that. I've tried "+yi':!$BROWSER https://github.com/<C-S-v> ($BROWSER is the browser declared in my .profile) but that doesn't put :!$BROWSER https://github.com/user/repo in the command to be executed with <CR>. Instead, nothing happens with I press the bound gX and only puts !$BROWSER https://github.com/ (plus the next key pressed) in the command area when I press another key after gX.

How can I put the text object under the cursor into an cmdline-mode command?

  • Assuming C-S-V is your OS copy-paste? Vim can’t do that from a mapping. But you can do a regular yank and put the contents of the register (e.g., register a) with C-r a
    – D. Ben Knoble
    Sep 17, 2022 at 11:21

2 Answers 2


It is not necessary to yank your path first. You can use <C-r><C-f> instead:

CTRL-R CTRL-F               *c_CTRL-R_CTRL-F* *c_<C-R>_<C-F>*
    CTRL-F  the Filename under the cursor

As mentioned in the comments, you can put the contents with <C-r>{register}. Thus, the RHS of the mapping would be

"+yi':!$BROWSER https://github.com/<C-r>+<CR>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.