On Sat, Oct 3, 2009 at 6:33 PM, Maxim Kim <haba...@gmail.com> wrote:

>
> Hi,
>
> Could anyone verify the next behaviour:
>
>    1. _vimrc should only have:
>       set nocp
>       set autochdir
>       set encoding=utf-8
>    2. in the shell do:
>       mkdir test
>       echo hello world > test\myfile
>       vim test\myfile
>
> My vim do not open test\myfile it just says: "test\myfile" [New
> DIRECTORY]
>
> Now if you delete 'set endoding=utf-8' from your _vimrc so you would
> have only:
> set nocp
> set autochdir
>
> and run:
>   vim test\myfile
> Vim opens this file successfully.
>
> Okay, now if I delete 'set autochdir' and return 'set encoding=utf-8'
> like this:
> set nocp
> set encoding=utf-8
>
> and run again:
>   vim test\myfile
> Vim opens this file successfully too.
>
> It looks like with the combination of 'set autochdir' and 'set
> encoding=utf-8' one can not open files in another dir from shell.
>
> So I use autocmd approach now:
>    autocmd BufEnter * silent! lcd %:p:h:gs/ /\\ /
> instead of autochdir.
>
>
> My vim is 7.2 with 1-148 patches applied on winXP.
>
> Best wishes,
>    Maxim.
>
>
The issue reason is command order.

When you do set autochdir, vim changes current dir and sets up current
buffer to use file "myfile" instead of "test\myfile".

Then "set encoding" brings up multibyte initialization, which re-writes
parameters for buffer using new encoding. During this process, file name is
changed from correct "myfile" to the original "test\myfile" and expanded to
"test\test\myfile".

I'm not sure if this really a bug and how it can be fixed, but simple change
of commands order brings us a workaround. Such vimrc:

set nocp
set encoding=utf-8
set autochdir

opens required file correctly.

Mikalai

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to