如何在 vim 中设置 UI 语言?

我在 reddit 上看到了 这个,它让我想起了我的一个抱怨: 它显示了德语的用户界面。我想听英语。但是由于我的操作系统是用德语设置的(我们办公室的标准) ,我想 vim 实际上是想提供帮助。

为了让 vim 切换 UI 语言,我必须执行哪些魔法咒语?我试过在各种场合谷歌搜索,但似乎找不到答案。

72064 次浏览

Start vim with a changed locale:

LC_ALL=en_GB.utf-8 vim

Or export that variable per default in your bashrc/profile.

:help language

:language fr_FR.ISO_8859-1

As Ken noted, you want the :language command.

Note that putting this in your .vimrc or .gvimrc won’t help you with the menus in gvim, since their definition is loaded once at startup, very early on, and not re-read again later. So you really do need to set LC_ALL (or more specifically LC_MESSAGES) in your environment – or on non-Unixoid systems (eg. Windows), you can pass the --cmd switch (which executes the given command first thing, as opposed to the -c option):

gvim --cmd "lang en_US"

As I mentioned, you don’t need to use LC_ALL, which will forcibly switch all aspects of your computing environment. You can do more nuanced stuff. F.ex., my own locale settings look like this:

LANG=en_US.utf8
LC_CTYPE=de_DE.utf8
LC_COLLATE=C

This means I get a largely English system, but with German semantics for letters, except that the default sort order is ASCIIbetical (ie. sort by codepoint, not according to language conventions). You could use a different variation; see man 7 locale for more.

Putting this line of code at the top of my _vimrc file saved my day:

set langmenu=en_US.UTF-8

For reference, in Windows (7) I just deleted the directory C:\Program Files (x86)\Vim\vim72\lang. That made it fallback to en_US.

I don't know why all of the above answers did not work for me. I kept getting errors about the locales not existing. Maybe it's a Windows thing. At any rate, my solution was to add this to my vimrc: let $LANG = 'en'

Ah, I spoke too soon. The menus of gVim are still in Japanese, but the intro screen is in English.

Ubuntu 10.10 + VIM 7.2 IMproved. Code below changes language for console vim. Add it at top of your vim.rc

if has('unix')
language messages C
else
language messages en
endif

Try this in _vimrc. It works with my win7.

set langmenu=en_US
let $LANG = 'en_US'
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim

These two lines at the begining of your .vimrc file will do the job:

let $LANG = 'en'
set langmenu=none

This worked for changing vim's menu language

set langmenu=en_US.UTF-8  [or just set langmenu=en for short]

But

language en

gave me an error sayng it couldn't set en as a language but this line did the job

:let $LANG = 'en'

The latter come from the Vim's docs. I added both lines at the beginning of the _vimrc file. I use a Windows 7 64 computer.

PS: this line changes both language and menus language

language messages en

In the .vimrc file (or _vimrc file if you are in windows)

Had similar issue, but neither one of above solution worked: https://superuser.com/questions/552504/vim-ui-language-issue/552523

I've resolved it by removing all vim packets and build vim from sources.

Hope it'll help someone.

Adding this to _vimrc works for me in windows 8:

set langmenu=en_US
let $LANG = 'en_US'

(note that _vimrc is in the same directory that contains my vim74 dir, thats the _vimrc file that vim reads at startup)

Two Vim installations on Windows

Nothing from here around have helped me until I have realized that I have 2 Vim installed.

  1. Git Bash via MinGW (Cygwin, mintty)
  2. A separate installation in the Program Files on Windows

Next command will filter you all watched vimrc-files and their locations.

vim --version | grep vimrc
  • _vimrc (Windows & CMD)
  • .vimrc (Bash for Git)
  • vimrc (has different locations for both)

1: Vim on Windows & CMD

Only renaming (deletion) of the lang folder helped me.

You can find it here C:\Program Files (x86)\Vim\vim80\lang

I tried all config settings listed here around and it was useless.

2.1: Git Bash through MinGW, Cygwin, mintty

For Git Bash I added language messages en_US at the top of C:\Program Files\Git\etc\vimrc

Of course, if you prefer to delete the lang folder you can find it here

  • C:\Program Files\Git\usr\share\vim\vim80\lang
  • C:\Users\User_name_xxx\AppData\Local\Programs\Git\usr\share\vim\vim80\lang for a local user installation.

2.2: Tuning only Git's Bash (MinGW64, Cygwin, mintty)

At the end, for Bash on Windows I have chosen to skip manipulations with vimrc

I opened C:\Program Files\Git\etc\bash.bashrc and added the following line

LANG='en_US'

or

LANG=C

Try to do not use en_US.UTF-8 because it forces some bash commands to produce weird chars. For example in find 'xxx_yyy_zzz_aaa.bbbddd' for a non-existing file.

If you're on Windows and don't want to be bothered issuing commands

To prevent the GUI from loading localization files

Just go to Program Files\Vim\vim80\lang and put an underscore as a prefix in front of all the files that look like they have something to do with your locale.

To prevent VIM itself from loading localization files

In the same folder as above, prefix with an underscore the folder named with your country code.

Note: Windows 10 will probably ask for Administrator privileges by raising a UAC warning.

By the way

This same technique can be applied to a lot of Unix/Linux tools ported on Windows, and generally all software packages where the localization files can readily be accessed. If you rename those to prevent the application from finding them, the fallback language will most probably be English.

Try adding this to your _vimrc:

let $LANG='en_US'

I simply disabled the native language support upon installation of gvim (thus making it a custom installation).

"Native Language Support" unchecked

Tested successfully with gvim82.exe under Windows 7.