On Sunday, August 19, 2018 at 7:01:23 PM UTC+8, Tony Mechelynck wrote:
> On Sun, Aug 19, 2018 at 12:50 PM, Sand Glass <youngluoyang@gmail.com> wrote:
> > 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?
>
> Oh, I see it now: the {rhs} of this mapping is an ex-command, so you
> need <CR> at the very end to make Vim execute the ex-command (both
> :let and :normal) and go back to Normal mode.
>
> Best regards,
> Tony.
I got it. Need <CR>/enter to normal mode.
nnoremap cP :let @p=expand('%:p')<CR>:norm "pp<CR>
By the way, I find another my environment operation bug.
For example, I need add the 'cP' shortcut function into my _vimrc. I am not sure the first time I will do it right. So I need save my editing file status into a file by using 'mksession' command. Now I have two files 'test.txt' and '_vimrc' in editing.
But mksession will save the gvim startup _vimrc contents, not the _vimrc file that I changed it. So next time when I open gvim, still load the old _vimrc. My _vimrc changes not affected.
When I write a vim script, how can I debug quickly?
I will open a new topic.
--
--
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.
Sunday, August 19, 2018
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment