Wednesday, March 9, 2016

Re: can I set a variable to store the file path in the vimrc and open the specific file in the command line like :e $myfile

2016-03-09 23:54 GMT+03:00 BPJ <bpj@melroch.se>:
> Den 2016-03-09 kl. 15:33, skrev Nikolay Aleksandrovich Pavlov:
>>
>> Unlike your variant which does not allow a huge number of characters
>> including spaces and `[]` which are not uncommon,
>
>
> Square brackets in filenames is common?

Every second *.ass/*.srt/… (subtitles) file. Spaces are common in
directory names you know where. And in subtitles, yes.

> Where did "ASCII alphanumerics, hyphen, underscore and period" go?
> I do often get files which originate on some non-utf-8 system (guess which!)
> containing what to their greator was things like "å ä ö", which reminds me
> to stick to filenames which are unlikely to get mangled when traveling.

Non-ASCII bytes in file names do not need escaping, even if your
&encoding is UTF-8 and file has a single 0x80 byte in its name (which
is not valid UTF-8). Problematic are:

1. Globbing characters: *, ? (AFAIR forbidden on Windows), [], {}.
2. Common expansion characters: $ (not forbidden in file names, and
not uncommon as well, though I saw only some automatically created
binary files like caches with them), `.
3. Vim own expansion characters: %, #. I use them in my file names,
and you may sometimes get `%` after downloading file from the web if
name is deduced automatically.
4. Separators: space, tab. Have not seen tab, but space is very common
when origin of the file worked on Windows and file cannot be described
with one word. *nix users prefer to use underscore or hyphen-minus.
5. ASCII control characters: newline (AFAIK other do not have
problems). Have seen in a file name that was not created by me for
testing purposes when I accidentally pasted something with newline
into KDE3 file manager (konqueror?). I am not using file managers on
my PC any more though.
6. Escaping characters: backslash.

Other characters do not need escaping. Most (everything when talking
about *nix) of the above is handled by fnameescape(). See also
https://github.com/vim/vim/issues/541.

>
> (And yes I do have files containing text in non-latin scripts -- quite a lot
> of them in fact -- but I stick to safe filenames.)

Even if you stick to safe filenames, this does not mean that
fnameescape() will do any harm. And it is more robust.

---

BTW, I used to have directory ~/*.* which contains many significant
files created in order not to turn ~ into a junk. It is now ~/a.a
though, but symlink `*.* -> a.a` is still there. Also see no harm in
naming books like `author-series-nr-title` where `author` is either
`transliterated_russian_name` or `%[english_name%]` (`%[` and `%]` are
present there literally), same for other fields.

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

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