Thursday, August 29, 2013

Re: get current file name with full path

On 30/08/13 00:50, Jerry Dai wrote:
> In insert mode, I will get current file name by:
> <C-R>%
>
> Is there anything similiar can give me a full hierarchical path?
>
> -- --
> Best Regards
> Jerry Dai
>

In a script, expand('%:p') would give you the result as a String. So, to
insert it at the Insert-mode cursor:

<C-R>=expand('%:p')<CR>
or
:map! <expr> <F7> expand('%:p')
(the latter would let you insert it by hitting F7 in Insert or
Command-line mode).

see
:help expand()
:help filename-modifiers
:help quote=
and for use in a mapping or abbreviation
:help :map-<expr>


Best regards,
Tony.
--
"The road to hell is paved with melting snowballs."
-- Larry Wall in <1992Jul2.222039.26476@netlabs.com>

--
--
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/groups/opt_out.

No comments:

Post a Comment