Sunday, August 19, 2018

Re: how to get file fullpath to vim register?

On Sunday, August 19, 2018 at 5:50:00 PM UTC+8, Tony Mechelynck wrote:
> On Sun, Aug 19, 2018 at 11:14 AM, Sand Glass <youngluoyang@gmail.com> wrote:
> > On Saturday, April 7, 2018 at 2:21:50 PM UTC+8, Ni Va wrote:
> >> Le samedi 7 avril 2018 08:02:45 UTC+2, Sand Glass a écrit :
> >> > Sometimes I need to copy my editing file's full path to my vim register, how can I get it?
> >>
> >>
> >>
> >> :let @" = expand('%:p') | norm p
> >>
> >> you can map this command.
> >>
> >>
> >> Nota: I do daily release of last Vim/Gvim ver on windows 64 bits by job_starting git clone, and nmake build if it can help.
> >
> > I try to map this command in _vimrc like this:
> > nnoremap cP :let @"=expand('%:p') | norm p
> > But does not work, Is here somthing wrong?
>
> In what manner does it "not work"? What happens when you hit cP in
> Normal mode then? Nothing? Or something else than what you expected?
> And what did you expect? The above mapping should insert the file's
> full path into the file itself immediately after the cursor. It won't
> work if you haven't yet given a name to the file.
>
> If you want instead to get the file's full path into the clipboard so
> you can paste it into a different application, then replace @" by @+
> and remove the " | norm p" at the end. For this you need access to the
> clipboard, e.g. running in gvim (of any flavour), or in a GUI-enabled
> Linux vim, or probably also on a Windows vim.exe but's been so long
> I've quit Windows I can't be sure in the latter case.
>
> Best regards,
> Tony.
I expect that after I hit 'cP' in normal mode, insert file's full path into the file itself immediately after the cursor.
But when I restart my gvim after I added this remap in _vimrc.
nnoremap cP :let @p=expand('%:p') | norm "pp
The started message hits me 'E353:Nothing in register p'
I try to remove '| norm "pp', and restart my gvim, no start error, and hit cP in normal mode. Command line show me the command:
:let @p=expand('%:p')
I need hit enter, and hit '"pp', to what I want.
How can I simply use 'cP' to get what I want?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: