Thursday, August 9, 2018

Re: Avoid "auto" short paths

Hi Bram, 

This is the company environment, is very common users have they own disk areas at the network of the company, which usually is a drive mapping and set at HOMEDRIVE and HOMEPATH. 

When I open the file , at %USERPROFILE% which is my local drive , vim internally change the path references from c:\Users\cinacio (%USERPROFILE%) to "~" .
But when vim expand "~" and exists HOMEDRIVE and HOMEPATH set, they use it.

I know I can force my HOME setting %HOME%=%USERPROFILE% at windows environment.
But I have others programs at my desktop and I don't know how this can affect them, so I would to avoid set the %HOME%

That's why I would force vim works always with absolute path.

Quote from the help :

 |   $HOME
 | Using "~" is like using "$HOME", but it is only recognized at the start of an
 | option and after a space or comma.
 | 
 | On Unix systems "~user" can be used too.  It is replaced by the home directory
 | of user "user".  Example:
 |     :set path=~mool/include,/usr/include,.
 | 
 | On Unix systems the form "${HOME}" can be used too.  The name between {} can
 | contain non-id characters then.  Note that if you want to use this for the
 | "gf" command, you need to add the '{' and '}' characters to 'isfname'.
 | 
 | On MS-Windows, if $HOME is not defined as an environment variable, then
 | at runtime Vim will set it to the expansion of $HOMEDRIVE$HOMEPATH.
 | 
 | NOTE: expanding environment variables and "~/" is only done with the ":set"
 | command, not when assigning a value to an option with ":let".
 | 
 | 
 | Note the maximum length of an expanded option is limited.  How much depends on
 | the system, mostly it is something like 256 or 1024 characters.



 | *$HOME-windows*
 | On MS-Windows, if $HOME is not defined as an environment variable, then
 | at runtime Vim will set it to the expansion of $HOMEDRIVE$HOMEPATH.
 | If $HOMEDRIVE is not set then $USERPROFILE is used.
 | 
 | This expanded value is not exported to the environment, this matters when
 | running an external command: >
 | :echo system('set | findstr ^HOME=')
 | and >
 | :echo luaeval('os.getenv("HOME")')
 | should echo nothing (an empty string) despite exists('$HOME') being true.
 | When setting $HOME to a non-empty string it will be exported to the
 | subprocesses.
 | 
 | 
 | Note the maximum length of an expanded option is limited.  How much depends on
 | the system, mostly it is something like 256 or 1024 characters.


Em qui, 9 de ago de 2018 às 15:45, Bram Moolenaar <Bram@moolenaar.net> escreveu:

Cesar Martins wrote:

> I'm using vim 8.1.1 in windows 8 at my work , corporate environment.
> Here we have the %HOMEPATH%, %HOMEDRIVE% set to "H:" and "\"
>
> What happen:
>
> I open a file at my Documents, path : C:\Users\cinacio\Documents\tmp1.txt
> Vim automatically short it to : ~\Documents\tmp1.txt
>   I can see that with ":ls" and "let v:oldfiles"
>
> The problem is, I use mksession and since I have HOMEPATH, HOMEDRIVE
> set , when I reopen vim and try recover my session, they don't found
> the file because they replace "~" to %HOMEDRIVE%+%HOMEPATH% , not
> %USERPROFILE% looking for the file at H:\Documents\tmp1.txt
>
> So, I want set some option to force the use of absolute path
> "c:\Users\cinacio" and not "~".
>
> Is this possible?

Why is there a difference in home directory?  Vim should get it right in
both cases, when storing and when reading the session.  Since you say
that the session stores "~\Documents\tmp1.txt" that looks correct, so
why is it different when you recover the session?

--
An indication you must be a manager:
You can explain to somebody the difference between "re-engineering",
"down-sizing", "right-sizing", and "firing people's asses".

 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
--
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:

Post a Comment