Gvim background Color

Source: Internet
Author: User
Tags configuration settings

background(Feihua) Reinstall the gvim7.4 (found gvim7.3 have displayed characters of the bug is upgraded), suddenly want to change the appearance of Windows Gvim, in a few blogs, but found unable to set up, so to the official website found a solution, posted here. Initial heuristic Workaround: Gvim cannot automatically save the current manual settings, such as fonts, color schemes. But by modifying the Gvim configuration file, you can load the settings we want. Modify the _VIMRC file in the Vim installation directory, set the color scheme to black background gray text Koehler scheme, set the font size to 14, so that not too hard to see. Copy the following code to the end of the _VIMRC file to be OK. Colo koehlerset guifont=courier_new:h14:cansi Open vimrc file-vim Tips Wiki Contents[show]What is VIMRC? Edit

The VIMRC file contains optional runtime configuration settings to initialize Vim when it starts. On Unix based systems, the file was named .vimrc , while on Windows systems it was named _vimrc .: Help VIMRC

You can customize Vim by putting suitable commands in your VIMRC. Here are a very simple example:

"Always wrap long lines:set wrap

Lines that begin with "is comments and is not read by VIM.

Search for file in vimrc_example.vim your Vim files for another example.: Help Vimrc-intro:help Vimrc_example.vim

To customize Vim for editing a specific file, or a specific type of file, can usemodelines, or auto commands, or filet Ype plugins. : Help Auto-setting:help filetype

Location of vimrcEdit

In Vim, your home directory are specified with $HOME . On Unix systems, this is your ~ directory. On Windows systems, the best-to-find the value $HOME of is from within Vim, as follows. These commands is useful to see what directories your Vim is using:

: Version:echo expand (' ~ '): Echo $HOME: Echo $VIM: Echo $VIMRUNTIME

Note the ' System VIMRC file ' and ' User vimrc file ' paths displayed by the :version command. The system VIMRC file can be created by a administrator to customize Vim for all users. In addition, each user can has his or her own user vimrc.

The output from :version includes the paths of the system and user VIMRC and GVIMRC files. For example:

   System VIMRC File: "$VIM/vimrc"     user vimrc file: "$HOME/.vimrc"      user exrc file: "$HOME/.exrc"  system GVIMRC F Ile: "$VIM/gvimrc"    user GVIMRC file: "$HOME/.GVIMRC"

If The GVIMRC files exist, they is used to configure Vim when the GUI version (GVIM) runs (after settings from VIMRC is Applied).

Settings for Gvim can also is placed in the VIMRC file using a has(‘gui_running‘) check:

If has (' gui_running ')  set guioptions-=t  "No toolbar  ColorScheme elflordendif

Although this can is useful to avoid the clutter of both a VIMRC and GVIMRC file, using the GVIMRC file have distinct BENEF It over the "gui_running" check. The most notable being, a GVIMRC file is sourced when using The:gui command to change a vim session into a gvim Sessi Mnl Anything that's in the VIMRC inside a "gui_running" check would not be applied since the VIMRC are only sourced when Vim I Nitially starts.

per-directory vimrcEdit

Vim can is configured so, when starting, it reads commands from a VIMRC file in the current directory, after reading The primary VIMRC. This was configured by adding to the set exrc primary VIMRC file. Setting ‘exrc‘ can be a security problem because it means Vim would execute commands from any VIMRC file in the directory WH Ere Vim is a started.:help ' exrc ' For that reason, set the ' secure ' option if your use of this option, and your may also want to Limit setting this option to when Vim is started from known "Safe" Directory Trees:

If GETCWD () ~=# ' ^\ (/my/safe/dir1/\|/my/safe/dir2/\) '  set secure exrcendif
Opening vimrcEdit

If vim finds your VIMRC file during startup, Vim would set the environment variable to the full path of the MYVIMRC VIMRC fil E. Similarly, if your GVIMRC file is found, the MYGVIMRC variable is set. Therefore, you can easily edit these files from within Vim:


Using the file name completion, you could type then press TAB until you see the :e $M desired variable. If you have want to see the path, type then :echo $M press Tab to see the variable, and presses Enter.

In Gvim, the Edit menu includes "Startup Settings" which would use a to $MYVIMRC Edit your VIMRC file. If $MYVIMRC does not exist, "Startup Settings" would create a new file using the "User VIMRC file" path shown by the :version com Mand.

Sourcing vimrcEdit

After you had saved changes to your VIMRC file, you can see the results by exiting from Vim, then starting Vim again.

If you is making frequent changes, you might want to "source" (execute) the changed VIMRC file without exiting:

: So $MYVIMRC "alternative that can used if VIMRC are the current File::so%

Warning Need to plan your VIMRC so re-sourcing does not cause problems. If you define commands, functions, or AUTOCMDS, you must make them remove or override the previous version when sourced, O R you'll get errors (for commands and functions) or duplicates (for Autocmds). Here is some examples that would work correctly when re-sourced:

"Use Bang (!) To redefine a command or function, if already defined.command! mycommand echo "Hello!" function! Myfunc ()  echo "Hello!" Endfunction "Put all Autocmds in some augroup and use au! To clear the Group.augroup vimrc_autocmds  au!  Autocmd Bufread * echo "File read!" Augroup END
Recovering from ErrorsEdit

Some errors in your VIMRC could prevent Vim from starting successfully. A reliable-handle that would is to rename your vimrc file and then edit the renamed file and then give it the correct Nam E. Alternatively, you could the start vim with a command like this (or use the "Gvim" if that's what you run VIM):

Vim-n-U none-u NONE

The -N starts in ' not compatible ' mode (that's, with extra Vim features). NONEThe argument (must is uppercase) skips initializations and does not read any VIMRC file ( -u ), and does not read an Y gvimrc file ( -U ).

You could now use :version the command to show the VIMRC path and then enter a command to edit the file.


To do

    • What else was needed to explain what VIMRC are, and how to use it, for a beginner?
    • Do something with the following text from the original tip (if keep it, need to fix text because it assumes you have used Some standard setup for installation, and assumes $VIM and $HOME be some default, and of course is for Windows):

On Windows, when you start Vim normally, it *either* runs the file "C:\Documents and Settings\ (user name) \_VIMRC" (wher E "(User name)" is replaced by the actual user name); *or*, if the file doesn ' t exist (it usually doesn ' t, for most users), it runs the file "C:\Program FILES\VIM\_VIMRC". Note If you have more than one disk your home may different; Do a ": Echo $HOME" To know where is your HOME. You should also see the _viminfo file in that directory.

    • Include Information for Windows:
      • When $HOME was not defined, it was created by combining $HOMEDRIVE and $HOMEPATH (if defined).
      • The recommended method to define and was to $HOMEDRIVE $HOMEPATH set the "Home folder ... Local path "On the Profiles tab of the User properties in Local Users and Groups (run Lusrmgr.msc).
      • I ' d say that this (the item above) was the recommended method to set your home folder in Windows. The Recommendes method to specify where your was _vimrc located (if it differs from your home folder) was to set the $HOME en Vironment variable. (Spiiph 00:16, July (UTC))
    • Link to the #vim-approved .vimrc ?;) (Spiiph 00:18, July (UTC))

Proposal Omit suggestions like the following, attempt to Auto-source VIMRC. I suspect that anyone needing to the read a tip to does this could get themselves in quite a bit of trouble. IMHO it's a lot more sensible to map a key to source a script so can control when it's is sourced. I Haven ' t bothered to put such a mapping in the tip so far because :so % the info seems more helpful, and entirely adequat E.--johnbeckett 11:56, August (UTC)

To source changes immediately, add to VIMRC:

Au bufleave ~/.vimrc:source ~/.VIMRC
Why isn't use
a bufwritepost instead of bufleave, so it'll source whenever you save?

Getting started tip ... I hit this page because I could not remember the "mkvim" command. I found it elsewhere and thought I ' d throw it in here. If you open vim, change some settings and get things how do you like the can use the This command

: mkv [File]

To automatically make a VIMRC file based on your current settings. The [file] part is optional; Vim would use the ~/.VIMRC by default. If you already has a. VIMRC and you attempt this we'll be is warned that. VIMRC already exists. You can use

To overwrite the existing file if you like. However once you did this your original. vimrc file was gone so that you could want to the back of any existing. VIMRC before try T His.
Using :mkvimrc to create .vimrc isn ' t a terribly good idea, since it saves mappings and abbreviations Setup B Y plugins. It can useful to copy currently set options to .vimrc however. (Spiiph 14:51, July (UTC))
Reference Source: Http://vim.wikia.com/wiki/Open_vimrc_file

Gvim background Color

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.