3

I have a strange behaviour which I do not understand. My aim is to open a textfile in vim. The textfile is in the Maildir e-mail format within the Maildir structure.

Information regarding the file

file -I 1410209267.M96643P11892.10140.foo.bar,S=4660,W=4787:2,S
1410209267.M96643P11892.10140.foo.bar,S=4660,W=4787:2,S: message/rfc822; charset=us-ascii
head -n3 1410209267.M96643P11892.10140.foo.bar,S=4660,W=4787:2,S
Delivered-To: foobar@gmail.com
Received: by 10.100.34.16 with SMTP id h16cs22337anh;
        Wed, 13 May 2009 04:48:51 -0700 (PDT)

Now the interessting part:

vim 1410209267.M96643P11892.10140.foo.bar,S=4660,W=4787:2,S

And the I get (| symbolize the cursor):

|
~
~

How can I open the file in vim?

What I discovered, it is something with the : in the filename. If I remove it from the filename, I can open it vim as wanted.

First Conclusion: It seems to be an issue with the file-system/OS and the handover to vim. Because, in python I can open the file with the colon in the filename.

I tried to escape the colon with \ but it did not have any positive effect. Vim seems not to find the file and open up in a new (empty) buffer.

vim 1410209267.M96643P11892.10140.foo.bar,S=4660,W=4787\:2,S

Additional information: Mac OSX 10.13.6; VIM - Vi IMproved 8.2

Workaround

I found a workaround for me:

cat 1410209267.M96643P11892.10140.foo.bar,S=4660,W=4787:2,S | vim -

jerik
  • 5,714
  • 8
  • 41
  • 80
  • Found some information regardign OSX and ``:``, but not really something to solve the problem: https://stackoverflow.com/a/13298479/1933185 – jerik Oct 31 '20 at 23:23
  • I'd suggest escaping such unusual sequences with single quotes, e.g.: `vim '1410209267.M96643P11892.10140.foo.bar,S=4660,W=4787:2,S'`. But I think this won't fix your problem. It could be a plugin. Have you tried `vim -u NORC '1410209267.M96643P11892.10140.foo.bar,S=4660,W=4787:2,S'`? – Ruslan Osmanov Oct 31 '20 at 23:27
  • Hi @RuslanOsmanov ``vim -u NORC '14...:2,S'`` did not work. But I found a workround for me. ``cat 14...:2,S | vim -``. – jerik Oct 31 '20 at 23:31
  • I'm on macOS too and Vim has no problem whatsoever opening a file with that name. – romainl Nov 01 '20 at 08:50
  • 2
    I suspect it's a Vim plugin that is attempting to interpret the `:`. There are several, for example https://github.com/bogado/file-line . Try `vim -u NONE` to skip initializing all rc files and see if the behavior persists. – ephemient Nov 01 '20 at 23:17
  • 1
    @ephemient you're right. ``vim -u NONE`` works, so its seems to be a plugin. – jerik Nov 03 '20 at 19:59

0 Answers0