Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use my .vimrc file in Cygwin?

Tags:

vim

cygwin

I just installed Cygwin on my work machine and would like to use the .vimrc file I use on my Linux box at home.

  • Is that possible, or does it need to have Cygwin-specific settings?
  • Where would I put the .vimrc file?

I'm a little unsure of what directory I'm being dropped into at the bash prompt under Cygwin, but I think I'd create a subdirectory called .vim there, right?

like image 394
Nathan Long Avatar asked Sep 29 '09 20:09

Nathan Long


People also ask

How do I open a .vimrc file in Terminal?

In the terminal, type vi . vimrc . This will create an empty vimrc system file which you want to use. In the file, type set number , and then hit Esc on the keyboard and type in :wq .

How do I access .vimrc files?

The global or system-wide vim configuration file is generally located under the /etc/vim/vimrc . This configuration file is applied to all users and when Vim is started this configuration file is read and Vim is configured according to this file contents.

How do I open a Vim file in Cygwin?

You need to run Cygwin's setup.exe again, and select the packages you want. Vim is not included in the default package. After installing Vim you may find that things just don't seem to be what you are used to. That is because Linux systems usually have a default .

How do I open a .vimrc file in Windows?

Opening vimrc Using file name completion, you could type :e $M then press Tab until you see the desired variable. If you only want to see the path, type :echo $M then press Tab to see the variable, and press Enter. In gvim, the Edit menu includes "Startup Settings" which will use $MYVIMRC to edit your vimrc file.


2 Answers

I launched vi as vi -V and got this:

chdir(/cygdrive/c/Users/johntron) chdir(/etc) chdir(/cygdrive/c/Users/johntron) could not source "/etc/virc" chdir(/cygdrive/c/Users/johntron) chdir(/cygdrive/c/Users/johntron) chdir(/cygdrive/c/Users/johntron) could not source "$HOME/.virc" chdir(/cygdrive/c/Users/johntron) chdir(/cygdrive/c/Users/johntron) chdir(/cygdrive/c/Users/johntron) could not source "$HOME/.exrc" 

Realizing vi was looking for .virc and not .vimrc like all the other *nix systems I've ever used, I just ran this to fix the problem:

cp ~/.vimrc ~/.virc 

... or if if you've configured symlinks:

ln -s ~/.vimrc ~/.virc 

I'm pretty sure this was a problem, because Cygwin installs vi, and not vi improved; however, the loading screen if you launch vi with no parameters still says vi improved. Regardless, I installed vim via setup.exe and running vim (not vi) does indeed try to load ~/.vimrc as expected. You can simply add an alias vi=vim to your ~/.profile to use the improved version by default.

like image 68
Johntron Avatar answered Sep 28 '22 16:09

Johntron


Cygwin (as of version 1.7.25) installs vi (not vim!) by default. If you also install vim you will have two commands: /usr/bin/vi and /usr/bin/vim.

Unlike in other *nix (e.g. debian) both commands slightly differ in their behaviour on starting vi/vim.

Both commands will load Vi Enhanced but they differ in the files they look for to initialize the editor:

/usr/bin/vi looks first for /etc/virc and then for $HOME/.virc

/usr/bin/vim looks first for /etc/vimrc and then for $HOME/.vimrc.

Both files (in /etc and in $HOME) will be sourced if found!

You can check it yourself entering vi -V and vim -V.

Use .vimrc if you call vim and .virc if you call vi. Or simply alias vi=vim for using .vimrc

like image 42
wolfrevo Avatar answered Sep 28 '22 15:09

wolfrevo