136976Re: expand('%:p') doesn't work properly when opening a new file in a non-existing directory?
- Mar 29, 2013On 30/03/13 03:50, hong@... wrote:
> Hi All,In this case, trying to write the file will answer "a/a.c: E212 Cannot
> According to the document of expand, "expand('%:p')" should be able to give full path of current buffer. This works properly when use vim to open an existing file or create a new file in an existing directory. But If I execute this command:
> gvim a/a.c
> where a is a non-existing directory. Then I run ":echo expand('%:p')", it gives 'a/a.c', which is not what I expected. Other modifiers just work as expected except '%:r'.
> Anyone have any ideas?
open file for writing", showing that there is *no* path to the file. But
after creating a subdirectory ./a in the current directory,
expand('%:p') gets a sensible value, and the write (if attempted) succeeds.
On Unix you might try
:exe '!mkdir -pv' expand('%:h')
if you really want to save the file under that name. (Of course it will
fail if you don't have the necessary directory-creation permissions.)
Does not run on any existing machine.
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@....
For more options, visit https://groups.google.com/groups/opt_out.
- << Previous post in topic Next post in topic >>