Sunday, July 28, 2013

Re: Vim Windows Autocommand Filename = 8.3

On Saturday, July 27, 2013 6:19:25 PM UTC-5, sfx2k wrote:
> I try to identify a file by its name.
>
> E.g. I have the following files:
>
> 2300039_2234552_779799_ABC.xml
> 2234439_2456644_123423_XYZ.xml
> and the following autocommand:
>
> autocmd BufRead,BufNewFile *.xml call CheckFileType()
> For a test case I just save the current filename to a global variable.
>
> function! CheckFileType()
> let g:filename = expand("%:p:t")
> endfunction
> When the file has finished loading, I echo the filename:
>
> echo g:filename
> The result: 223443~1.XML
>

That is REALLY weird, because the :p is supposed to cause Vim to expand 8.3-style names according to :help filename-modifiers.

What happens if you use expand("<afile>:p:t") instead? Possibly as an argument to the function instead of in the function, I don't recall exactly when that works.

> But for identification I need the complete filename!
>
> When I reload the file afterward and echo the filename again, I get the long filename. wtf???
>
> This behavior only appears, when loading the file from extern (e.g. "C:\Vim\vim73\gvim.exe" --remote-silent C:\2234439_2456644_123423_XYZ.xml). When loading from intern (:e) everything is as expected.

The --remote-silent stuff uses :drop internally, if I recall. Does :drop work the same as :e or the same as --remote-silent or something different?

>
> Any ideas?
>

Are you actually using the command-line with --remote-silent as you show, or through a shortcut? If the latter, you can try the suggestion in :help vim-default-editor.

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