gvim背景配色

2023-05-16

背景(feihua)
重新安装了gvim7.4后(发现gvim7.3有显示字符的bug便升级了),忽然想改一下windows下gvim的外观,在看了几个博客,却发现无法设置,于是到官网找到了解决方案,贴在此处。
最初试探的解决方法:
gvim无法自动保存当前手动的设置,比如字体、配色方案。但是修改一下gvim的配置文件,就可以载入我们所希望的设置。
修改vim安装目录下的_vimrc文件,把配色方案设置成黑色背景灰色文字的koehler方案,设置字体大小为14,这样看得不会太辛苦。把下面的代码复制到_vimrc文件的末尾就OK了。
colo koehler
set guifont=Courier_New:h14:cANSI
 
 

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 is named .vimrc, while on Windows systems it is named _vimrc. :help vimrc

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


" Always wrap long lines:
set wrap
  

Lines that begin with " are comments and are not read by vim.

Search for file vimrc_example.vim in 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, you can usemodelines, or auto commands, or filetype plugins. :help auto-setting :help filetype

Location of vimrcEdit

In Vim, your home directory is specified with $HOME. On Unix systems, this is your ~directory. On Windows systems, the best way to find the value of $HOME is from within Vim, as follows. These commands are 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 :versioncommand. The system vimrc file can be created by an administrator to customize Vim for all users. In addition, each user can have 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 file: "$VIM/gvimrc"
    user gvimrc file: "$HOME/.gvimrc"
  

If the gvimrc files exist, they are used to configure Vim when the GUI version (gvim) runs (after settings from vimrc are applied).

Settings for gvim can also be placed in the vimrc file using a has('gui_running') check:


if has('gui_running')
  set guioptions-=T  " no toolbar
  colorscheme elflord
endif
  

Although this can be useful to avoid the clutter of both a vimrc and gvimrc file, using the gvimrc file has distinct benefits over the "gui_running" check. The most notable being that a gvimrc file is sourced when using the :gui command to change a vim session into a gvim session. Anything that was in the vimrc inside a "gui_running" check will not be applied since the vimrc is only sourced when Vim initially starts.

Per-directory vimrcEdit

Vim can be configured so that, when starting, it reads commands from a vimrc file in the current directory, after reading the primary vimrc. This is configured by adding set exrcto the primary vimrc file. Setting 'exrc' can be a security problem because it means Vim will execute commands from any vimrc file in the directory where Vim is started.:help 'exrc' For that reason, set the 'secure' option if you use this option, and you 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 exrc
endif
  

Opening vimrcEdit

If Vim finds your vimrc file during startup, Vim will set the MYVIMRC environment variable to the full path of the vimrc file. Similarly, if your gvimrc file is found, the MYGVIMRCvariable is set. Therefore, you can easily edit these files from within Vim:


:e $MYVIMRC
:e $MYGVIMRC
  

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. If $MYVIMRC does not exist, "Startup Settings" will create a new file using the "user vimrc file" path shown by the :version command.

Sourcing vimrcEdit

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

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


:so $MYVIMRC
" Alternative that can be used if vimrc is the current file:
:so %
  

Warning You may 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, or you will get errors (for commands and functions) or duplicates (for autocmds). Here are some examples that will 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 may prevent Vim from starting successfully. A reliable way to handle that would be to rename your vimrc file, then edit the renamed file, then give it the correct name. Alternatively, you could start Vim with a command like this (or use "gvim" if that is how you run Vim):


vim -N -u NONE -U NONE
  

The -N starts in "not compatible" mode (that is, with extra Vim features). The NONEargument (must be uppercase) skips initializations and does not read any vimrc file (-u), and does not read any gvimrc file (-U).

You could now use the :version command to show the vimrc path, then enter a command to edit that file.

CommentsEdit

 TO DO 

  • What else is needed to explain what vimrc is, 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 are 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" (where "(user name)" is replaced by the actual user name); *or*, if that file doesn't exist (it usually doesn't, for most users), it runs the file "C:\Program Files\vim\_vimrc". Note that if you have more than one disk your home may be different; do an ":echo $HOME" to know where is your home. You should also see the _viminfo file in that directory.

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

Proposal Omit suggestions like the following that attempt to auto-source vimrc. I suspect that anyone needing to read a tip to do 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 you can control when it is sourced. I haven't bothered to put such a mapping in the tip so far because the :so % info seems more helpful, and entirely adequate. --JohnBeckett 11:56, 23 August 2008 (UTC)

To source changes immediately, add to vimrc:


au BufLeave ~/.vimrc :source ~/.vimrc
  
Why not use a BufWritePost instead of BufLeave, so it will 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 you like you can use this command


:mkv [file]  

to automatically make a vimrc file based on your current settings. The [file] part is optional; vim will use ~/.vimrc by default. If you already have a .vimrc and you attempt this you we will be warned that .vimrc already exists. You can use


mkv!  
to overwrite the existing file if you like. However once you do this your original .vimrc file is gone so you may want to back up any existing .vimrc before you try this.
Using  :mkvimrc to create  .vimrc isn't a terribly good idea, since it saves mappings and abbreviations setup by plugins. It can be useful to copy currently set options to  .vimrc however. ( Spiiph 14:51, 27 July 2009 (UTC))
参考来源:http://vim.wikia.com/wiki/Open_vimrc_file
              http://blog.sina.com.cn/s/blog_4ddef8f80100wjs1.html

转载于:https://www.cnblogs.com/7explore-share/p/4706102.html

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

gvim背景配色 的相关文章

  • vim或gvim的配置(推荐)

    本文简述如何跟换gVim的字体和选择喜欢的配色方案 xff1a 1 下载配色方案 xff1a gVim官网提供了很多配色方案 xff0c 可以根据自己的需要来选择下载 xff0c 本人比较喜欢深色背景系列的 xff0c 所以以下列举一些 x
  • GVIM设置默认字体、背景颜色以及行号

    GVIM设置默认字体 背景颜色以及行号 xff1a 1 打开terminal去到根目录下 2 输入gvim vimrc打开空白文件 3 依次输入 set nu set guifont 61 Monospace 15 colorscheme
  • ubuntu 11.04 安装gvim

    折腾了N久 xff0c 终于安装成功了 1 在www vim org上 下载 源码包 vim 7 3 tar bz2 2 开发库libncurses5 dev安装 xff1a sudo apt get install libncurses5
  • gvim中文乱码解决方案

    http www cnblogs com login007 archive 2011 09 14 2176764 html 这东西没必要记在脑子里面 xff0c 还是贴这里备用把 set fileencodings 61 utf 8 gb2
  • Gvim的字体、颜色、背景设置

    http apps hi baidu com share detail 5348127 很多朋友在使用Linux文本编辑器Gvim的时候 xff0c 遇到这样的问题 xff0c 字体太小 xff0c 或者想还一种自己个喜欢的字体 这可通过e
  • vim(gvim)配合ZendCodeAnalyzer检查php语法

    http www vimer cn 2011 01 vimgvim E9 85 8D E5 90 88zendcodeanalyzer E6 A3 80 E6 9F A5php E8 AF AD E6 B3 95 html 本博之前有写过一
  • 在Gnome下让GVim自动最大化

    http www linuxidc com Linux 2011 03 33922 htm 让GVim在启动的时候自动最大化 xff0c 在Windows下面不是个问题 xff0c 只要在配置文件中加一行 au GUIEnter simal
  • GVIM的配置/使用

    关于GVIM的配置 使用 以我个人喜好配置 配置文件在用户目录下的 vimrc里 配置完后 xff0c 保存并bash一下即可 一 配置 xff1a 根据自己的喜好配置了一点点 colorscheme darkblue span class
  • gvim配置默认字体、配色等

    gvim配置默认字体 配色等 1 打开软件 xff0c 选择编辑 gt 启动设定 2 在其中添加自己的配置命令 xff0c 例如 xff1a filetype on 34 关闭自动备份 set noundofile set nobackup
  • gvim背景配色

    背景 xff08 feihua 重新安装了gvim7 4后 xff08 发现gvim7 3有显示字符的bug便升级了 xff0c 忽然想改一下windows下gvim的外观 xff0c 在看了几个博客 xff0c 却发现无法设置 xff0c
  • GVIM设置背景颜色

    首先找到GVim的安装目录 xff0c 在安装目录下你可以发现一个 vimrc文件 使用文本编辑器打开后在里面添加两行代码即可 xff1a 代码如下 set gfn 61 Courier New h14 colorscheme torte
  • gVim配色和字体选择

    本文简述如何跟换gVim的字体和选择喜欢的配色方案 xff1a 1 下载配色方案 xff1a gVim官网提供了很多配色方案 xff0c 可以根据自己的需要来选择下载 xff0c 本人比较喜欢深色背景系列的 xff0c 所以以下列举一些 x
  • Vim/gVim 中文显示为乱码的解决办法

    打开vimrc文件 xff0c 在vim的安装目录下可以找到该文件 xff0c 或在windows下是在vim gvim下输入 edit vim vimrc 在文件的末尾添加一句 set fileencodings 61 utf 8 gbk
  • 简单的整理一下VIM环境配置和插件安装

    http www zhaiqianfeng com 2017 02 install vim plugins html 先占个坑 周末有时间再写
  • 全世界最好的编辑器VIM之Windows配置(gvim)

    全世界最好的编辑器VIM之Windows配置 gvim vundle插件管理 NERDTree插件 ctrlp插件 vim nerdtree tabs插件等 vim本来就是很强大 很方便的编辑器 再加上这些杀手级的插件 那就真的无敌了 官方
  • GVIM的默认初试界面大小、启动位置设置

    打开GVIM安装目录下的 vimrc文件 在其中添加配置内容 winpos 100 100 设置初始界面位置 set lines 25 columns 85 设置初始界面大小 若要设置代码折叠功能 用空格键控制折叠开关 set folden
  • Windows 下最实用的 Gvim 配置

    一直以来被称为编辑器之神的 vim 在 Windows 下很难发挥其强大的功能 本文从实用的角度阐述如何调校出一个比较好用的 vim 不过仍然要说明下 在众多 vim 构建版本中 Mac OS 平台的 MacVim 是我认为最好用的一个版本
  • gvim 编译选项没支持Python. gvim is not python supported

    windows 安装 vim tux 该版本开启了所有的编译支持选项
  • [GVIM] Increasing or decreasing numbers

    原文链接 https vim fandom com wiki Increasing or decreasing numbers In normal mode typing Ctrl A will increment the next num
  • Gvim高级操作006--verilog例化代码对齐

    Gvim高级操作006 verilog例化代码对齐 Gvim如果没有安装对齐插件的情况下 无法通过快捷操作实现verilog例化代码对齐 但是可以通过正则表达式匹配插入空格实现代码对齐 基本原理是 删除空格 点号 和信号之间不能有空格 左括

随机推荐

  • TX2-start 6 CPU kernel-开启高功耗模式

    1 TX2简介 Jetson TX2是由一个GPU和一个CPU集群组成 CPU集群由双核denver2处理器和四核ARM Cortex A57组成 xff0c 通过高性能互连架构连接 拥有 xff16 个CPU核心和一个GPU xff0c
  • 生成正太随机变量

    clc clear close format long syms u v x y u1 u2 u3 u3 u x1 x2 x3 x4 x5 d L int int int int 1 x5 x4 1 x4 x3 1 x3 x2 1 x2 x
  • 【opencv基础】OpenCV installation stuck at [ 98%] Built target opencv_perf_stitching with no error...

    前言 按照官网步骤安装opencv的过程中进行到98 时一直没有继续进行 原因 后台一直在编译运行 xff0c 只需等待即可 xff0c 参考here xff1b well turns out it gets stuck for quite
  • PX4的UORB通信机制

    在Firmware的msg文件夹里面 xff0c 里面有很多 msg结尾的文件 xff0c 这些msg文件在编译的时候可以生成h头文件 xff0c 这些编译过程中生成的头文件一般是保存在build default src module uo
  • ubuntu下安装和更新R语言

    ubuntu 下安装和更新 R 语言 本文主要讲解在 ubuntu 下如何安装和更新 R 语言 将分别介绍什么是 R 语言 xff0c 简单方法安装 R 语言 xff0c 通过更新源来安装或更新 R 语言 xff0c 和安装 R 语言集成开
  • Linux 中各个文件夹的作用

    根目录 包含了几乎所的文件目录 相当于中央系统 进入的最简单方法是 xff1a cd boot 引导程序 xff0c 内核等存放的目录 这个目录 xff0c 包括了在引导过程中所必需的文件 在最开始的启动阶段 xff0c 通过引导程序将内核
  • 转:Fix Bug的五个阶段

    一个非常严重和困难的bug xff0c 能够成就一个饱经沧桑深受压力的有经验的专业程序员的职业生涯 经受这种考验的创伤程度 xff0c 相当你受到了一次严重的身体伤害 xff0c 离婚 xff0c 或是家庭成为的离世 研究人员在研究了计算机
  • 10.app后端选择什么开发语言

    在qq上 xff0c 经常看到有创业团队的创始人一直都招不到技术人员 xff0c 除了项目的因素外 xff0c 很大的原因就是所需要掌握的开发语言偏门 通过阅读本文 xff0c 详细了解选择开发语言的核心原则 xff0c 使各位心里对开发语
  • dell服务器系统开机提示错误解决方法

    DELL 服务器有时会若硬件的改动 xff0c 在开机以后会提示错误信息 信息一般会提示在显示器上 xff0c 以后举出如下信息的解决办法 信息 原因 纠正措施 Alert iDRAC6 not responding Rebooting i
  • 卡尔曼滤波原理

    卡尔曼滤波原理 原文链接 xff1a http www bzarg com p how a kalman filter works in pictures https blog csdn net u010720661 article det
  • 在网络直播中什么叫推流

    参考 xff1a 推流 xff0c 指的是把采集阶段封包好的内容传输到服务器的过程 其实就是将现场的视频信号传到网络的过程 推流 对网络要求比较高 xff0c 如果网络不稳定 xff0c 直播效果就会很差 xff0c 观众观看直播时就会发生
  • Hello, Weka

    转自http dreamhead blogbus com logs 16813833 html Weka xff0c 是一个用Java编写的数据挖掘软件 数据挖掘 xff0c 从字面上来看 xff0c 它是一个从数据中找寻有用信息的过程 x
  • ubuntu基础知识与技巧

    root用户与超级用户的切换 1 sudo i 2 sudo su 3 su root 安装升级 查看软件xxx安装内容 dpkg L xxx 查找软件库中的软件 apt cache search 正则表达式 或 aptitude sear
  • linux多线程编程书籍推荐:linux大牛之路从这几本书開始总结

    linux多线程编程是指基于Linux操作系统下的多线程编程 xff0c 包含多任务程序的设计 xff0c 并发程序设计 网络程序设计 数据共享等 Linux系统下的多线程遵循POSIX线程接口 xff0c 称为pthread 编写Linu
  • Google Tango初学者教程

    Getting Started with the Tango Java API In this tutorial we 39 ll go through setting up your build environment and compi
  • 在虚拟机下运行gazebo,关于vmw_ioctl_command error Invalid argument错误

    开发环境 xff1a windows10 43 vmware player 43 ubuntu14 04 43 ROS indigo 运行 xff1a gazebo 前提条件 xff1a 安装gazebo xff1a sudo apt ge
  • 做杜邦线(假)教程

    好像国外叫 跳线 xff08 jump wire xff09 xff0c 我们叫杜邦线 xff0c 不清楚这个名字的来历 某宝上的杜邦线 xff0c 质量良莠不齐 xff08 如同很多别的不是杜邦线的商品一样 xff09 吃过几次亏后 xf
  • PX4的workqueue

    Workqueue相当于是中断子程序 xff0c 然后在queue的cycle里面要注意 xff0c 不能在cycle函数里面用printf打印 xff0c 在cycle里面printf函数是打印不出来的 也不能在cycle里面用while
  • windows10安装Python环境

    下载Python交互解释器 xff08 俗称 环境 xff09 登录python官网 xff1a www python org 进 入 官 网 首 页 xff0c 选 择 Downlaods 下 面 对 应 的 系 统 版 本 xff08
  • gvim背景配色

    背景 xff08 feihua 重新安装了gvim7 4后 xff08 发现gvim7 3有显示字符的bug便升级了 xff0c 忽然想改一下windows下gvim的外观 xff0c 在看了几个博客 xff0c 却发现无法设置 xff0c