简体   繁体   中英

vim - _vimrc file on Windows 8 not working

I found this question but it didn't help. The solution in this is what I tried but it didn't work.

I am trying to create an _vimrc file on my Windows 8 computer so that the syntax of my code in vim is 1) highlighted by default and 2) maintains indents.

I entered

echo %UserProfile%

into the command prompt and it gave me C:\\Users\\Username.

I used vim to create a _vimrc file in C:\\Users\\Username and added

set autoindent

syntax on

to it. However, these changes do not register in vim.

Most questions I could find online are for Unix where the home directory is ~. The questions that did apply to Windows said to create the file in the C:\\Users\\Username directory which is what I'm doing.

I tried closing and reopening my command prompt but it didn't help.

Sorry if this is a really simple question; I don't use user variables that often.

The presence of /usr/share/vim/vimrc in the output of :scriptnames indicates that you are using a version of Vim provided by some unix-like compatibility layer like cygwin instead of a regular Windows build.

From the user's perspective, the cygwin environment is completely segregated from the Windows environment and you are expected to use/customize it like you would on an actual unix-like system. Mixing Windows and "Linux" (huge quotes, here) concerns is not a very good idea in such a context.

In Vim, :echo $HOME should tell you what your $HOME is from Vim's POV.

If you are indeed using cygwin, cygwin's $HOME is usually located here from Windows' POV:

C\cygwin\home\username

while Windows' $HOME is usually located here from cygwin's POV:

/cygdrive/c/Users/username

In short…

  • if your Vim is a regular Windows program, the standard location for your config is:

     C\\Users\\username\\_vimrc C\\Users\\username\\vimfiles\\ 

    You can use both the console and the explorer to deal with those files and directories.

  • if your Vim is provided by cygwin, the standard location for your config is:

     /home/username/.vimrc /home/username/.vim/ 

    You are pretty much forced to use the "Cygwin Terminal" to deal with those files and directories unless you get how those are mapped to Windows paths.

    Avoid thinking in Windows terms.

I ran into a similar problem on Windows 7 and 10. VIM's installer created a default vimrc file in the installation directory (in my case c:\\Program Files (x86)\\Vim ).

After deleting this file, VIM looks in my home directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM