Windows下Gvim的安装与配置

1.简述

Vim是Linux上著名的文本编辑器,他是早年的Vi编辑器的加强版。Gvim是Vim的图形前端,它是跨平台的编辑器,基本上主流的操作系统上面都有它的版本。此处记录在Windows下的安装与配置,在Linux下的网上教程很多。

因为在公司实习时,主要用的两台电脑放在公司,下班不想带回实验室,所以就在实验室的电脑上安装GVIM,用于配合在Linux下的Verilog训练。

2.GVIM的安装

最新安装包下载官方网址download : vim online

 安装步骤比较简单,双击可执行应用程序即可

3.GVIM的基础配置

双击打开gVim 9.0,效果如图:

可以直接编辑GVIM安装路径下的_vimrc文件

 

 

 具体配置如下:

" Vim with all enhancements
source $VIMRUNTIME/vimrc_example.vim

" Remap a few keys for Windows behavior
source $VIMRUNTIME/mswin.vim

" Mouse behavior (the Unix way)
behave xterm

" 关闭vi兼容模式
set nocompatible

" 语法高亮度显示
syntax on

" 设置行号
set nu

"自动换行
:set wrap


"突出显示当前行
:set cursorline

"光标所在的当前列高亮
:set cursorcolumn

"防止中文注释乱码
set fileencoding=utf-8
set fenc=utf-8
set fencs=utf-8,usc-bom,euc-jp,gb18030,gbk,gb2312,cp936,big-5                    
set enc=utf-8
let &termencoding=&encoding

"处理菜单乱码
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim

"括号自动补充
inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap < <><Esc>i
inoremap { {}<Esc>i
inoremap ' ''<Esc>i
inoremap " ""<Esc>i
"inoremap { {<CR>}<Esc>O     	 "有的时候需要{}中间自动回车空一行,有的时候不需要,我们暂时不需要


"设置字体和字体大小
:set gfn=kaiti_GB2312:h15

" 设置tab4个空格
set tabstop=4
set expandtab

"程序自动缩进时候空格数
set shiftwidth=4

"退格键一次删除4个空格
set softtabstop=4
autocmd FileType make set noexpandtab

" vim使用自动对起,也就是把当前行的对起格式应用到下一行
set autoindent

" 依据上面的对起格式,智能的选择对起方式,对于类似C语言编写上很有用
set smartindent

" 在编辑过程中,在右下角显示光标位置的状态行
set ruler

" 搜索忽略大小写 
set ignorecase 

" 启用鼠标
set mouse=a 

" Vim 的默认寄存器和系统剪贴板共享
set clipboard+=unnamed  


" 在状态列显示目前所执行的指令
set showcmd

" 设置颜色主题
colorscheme darkblue




" 取消自动备份与缓存
set nobackup  

set backspace=indent,eol,start


" Use the internal diff if available.
" Otherwise use the special 'diffexpr' for Windows.
if &diffopt !~# 'internal'
  set diffexpr=MyDiff()
endif
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg1 = substitute(arg1, '!', '\!', 'g')
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg2 = substitute(arg2, '!', '\!', 'g')
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let arg3 = substitute(arg3, '!', '\!', 'g')
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      if empty(&shellxquote)
        let l:shxq_sav = ''
        set shellxquote&
      endif
      let cmd = '"' . $VIMRUNTIME . '\diff"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  let cmd = substitute(cmd, '!', '\!', 'g')
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  if exists('l:shxq_sav')
    let &shellxquote=l:shxq_sav
  endif
endfunction

 保存退出,效果如下:

 

 

 到此整个GVIM基本上就安装和配置完成了,在实现基本配置的情况下,添加了自动匹配括号和高亮十字架的功能,对于Verilog代码的速度输出有很大的提升,后面随着学习的深入再做进一步的优化。

 

 

相关文章

学习编程是顺着互联网的发展潮流,是一件好事。新手如何学习...
IT行业是什么工作做什么?IT行业的工作有:产品策划类、页面...
女生学Java好就业吗?女生适合学Java编程吗?目前有不少女生...
Can’t connect to local MySQL server through socket \'/v...
oracle基本命令 一、登录操作 1.管理员登录 # 管理员登录 ...
一、背景 因为项目中需要通北京网络,所以需要连vpn,但是服...