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代码的速度输出有很大的提升,后面随着学习的深入再做进一步的优化。

 

 

  • 5
    点赞
  • 33
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

A u g

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值