Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bundled Vim.exe seems to need filetype=mac in vimrc instead of filetype=dos #272

Closed
IsaacRemuant opened this issue Aug 12, 2015 · 4 comments

Comments

@IsaacRemuant
Copy link

I'm not sure if this is an actual issue or I botched something up but when I call vim from git bash

where

C:\Program Files\Git\usr\bin\vim.exe  <- this one as opposed to the one below
C:\Windows\vim.bat

It has several problems with ^M characters:

$ vim

Error detected while processing /c/Users/my_user/.vimrc:
line   13:
E492: Not an editor command: ^M
line   16:
E488: Trailing characters: nocompatible^M
line   17:
E492: Not an editor command: ^M
line   18:
E15: Invalid expression: has('win32') || has('win64')^M
line  211:
E171: Missing :endif
Press ENTER or type command to continue

I've tried saving the file in different formats and the filetype=mac format "solved" the issue for the vim in git bash but that's not really a solution since the other vim naturally expects fileformat=dos in windows.

I use this .vimrc across computers in Linux/Win without issue and it used to work in the older git bash (msysgit 1.95).

edit: minor mistake (meant fileformat/s, not filetype)

@dscho
Copy link
Member

dscho commented Aug 12, 2015

I guess that $HOME/.vimrc has DOS line endings (not Mac line endings, you have CRLF at the end of each line, not CR, otherwise the .vimrc would be interpreted as a single line).

You can fix this using the command-line dos2unix $HOME/.vimrc.

Alternatively, you could work on https://github.com/git-for-windows/MSYS2-packages/tree/master/vim to teach vim.exe itself to handle DOS line endings. That would be a very welcome way to say thanks to the Git for Windows project; you will find the following documentation helpful: https://github.com/git-for-windows/git/wiki/How-to-participate#fix-bugs-or-add-features-in-the-git-code-itself and https://github.com/git-for-windows/git/wiki/Package-management#rebuild-packages

@dscho dscho closed this as completed Aug 12, 2015
@IsaacRemuant
Copy link
Author

Hi, thanks for the quick reply. I thought dos2unix and similar tools did the same thing as set ff and set ffs. I've tried them with similar results. I've even used a vimrc that is in unix format and loads just fine from gvim.exe but I have no clue as to why it only works in the git-bash vim with a mac fileformat.

I'm probably too swamped at the moment to take a look but I'll save those links to read later and see if I'm able to contribute. Cheers.

@leif81
Copy link

leif81 commented Sep 4, 2015

I just upgraded from Git for Windows 1.9.4 to 2.5.1 and noticed the same issue. Doing a dos2unix on my ~/.vimrc is a one time thing so not a big deal, just a little rough edge.

However I've also noticed that the .vimrc I keep in the root of each of my git repo's causes a similar problem. When I clone the repo the .vimrc will have Windows line endings. So I have to dos2unix it too. Also the next time I open Git Gui I get a warning about the file (.vimrc has no changes.) and the .vimrc appears in the unstaged changes panel. I've noticed that staging the .vimrc will cause another warning (warning: LF will be replaced by CRLF in .vimrc.), but the file will then disappear for good from Git Gui. It's not critical, but just another little rough edge.

@dscho
Copy link
Member

dscho commented Sep 4, 2015

@leif81 yes, I expected this to be not only a one-time problem. That is why I was a bit disappointed that my suggestions to fix it properly were ignored. But maybe that changes now, what with you noticing the same problem?

It is pretty easy, really. Just install the Git for Windows SDK, then call the following commands:

pacman -Syu base-devel binutils
cd /usr/src/MSYS2-packages
git fetch
git checkout master

After that, you need to open an MSys2 shell by running the msys2_shell.bat script in the top-level directory of the SDK (this is really important because you are going to build an MSys2 program, while the default SDK terminal is set up to build MinGW programs). This will open another mintty -- note the MSYS: prefix in the window title -- in which you can build the complete vim package:

cd /usr/src/MSYS2-packages/vim
makepkg -s

Once it is built completely, you have the source code at your fingertips in the src/ subdirectory. I typically run git init && git add . && git commit -m initial in there (or in the subdirectory into which the source code was actually checked out) and then start hacking.

Please feel free to ask for any more information you need.

dscho added a commit to dscho/MSYS2-packages that referenced this issue Sep 15, 2015
When sharing Windows' home directory, we have to expect that the
`.vimrc` file can have DOS line endings.

Let's be lenient about this, as well as all other input we get, and just
handle CR/LF as well as LF line endings.

We still behave as before, otherwise.

This fixes git-for-windows/git#272

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/MSYS2-packages that referenced this issue Sep 15, 2015
When sharing Windows' home directory, we have to expect that the
`.vimrc` file can have DOS line endings.

Let's be lenient about this, as well as all other input we get, and just
handle CR/LF as well as LF line endings.

We still behave as before, otherwise.

This fixes git-for-windows/git#272 and
git-for-windows/git#364

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/MSYS2-packages that referenced this issue Sep 15, 2015
When sharing Windows' home directory, we have to expect that the
`.vimrc` file can have DOS line endings.

Let's be lenient about this, as well as all other input we get, and just
handle CR/LF as well as LF line endings.

We still behave as before, otherwise.

This fixes git-for-windows/git#272 and
git-for-windows/git#364

Signed-off-by: Johannes Schindelin <[email protected]>
dscho added a commit to dscho/MSYS2-packages that referenced this issue Sep 15, 2015
When sharing Windows' home directory, we have to expect that the
`.vimrc` file can have DOS line endings.

Let's be lenient about this, as well as all other input we get, and just
handle CR/LF as well as LF line endings.

We still behave as before, otherwise.

This fixes git-for-windows/git#272 and
git-for-windows/git#364

Signed-off-by: Johannes Schindelin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants