0


Verilog编辑器Gvim的配置

1.Gvim下载

Ubuntu:

sudo apt-get install vim
sudo apt-get install gvim

CentOS7:

sudo yum install vim
sudo yum install gvim

win:

download : vim onlinehttps://www.vim.org/download.php![](https://img-blog.csdnimg.cn/direct/d8dc0d706c8a451ba79ac44f2f6142d3.png)

2.配置位置

win:安装目录下

linux:在home目录下,如果没有就新建

可以使用我的配置,替换掉图中的两个文件即可,下载地址如下:

链接:https://pan.baidu.com/s/13U_AIwD-tuE5T21cxitjfw
提取码:9s5m

3.基本配置

3.1.字体和颜色设置

" =============================================================
"                         字体和颜色设置
" =============================================================
"自动开启语法高亮"
syntax enable

"设置字体"
set guifont=Monospace\ 13

"设置主题样式"
colorscheme desert
"set background=light                        

"高亮显示当前行"
set cuc
set cul

3.2.文字处理设置

" =============================================================
"                     文字处理设置
" =============================================================
"使用空格来替换Tab"
set expandtab

"设置所有的Tab和缩进为4个空格"
set tabstop=4

"设定<<和>>命令移动时的宽度为4"
set shiftwidth=4

"使得按退格键时可以一次删除4个空格"
set softtabstop=4
set smarttab
autocmd FileType make set noexpandtab

"缩进,自动缩进(继承前一行的缩进)"
set autoindent 
set cindent

"智能缩进"
set si

"自动换行”
set wrap

"设置软宽度"
set sw=4

"行内替换"
set gdefault

3.3.界面设置

" =============================================================
"                       界面设置
" =============================================================
"显示光标位置的状态行"
set ruler

"设置命令行的高度"
set cmdheight=1

"显示行数"
set number

"关闭遇到错误时的声音提示"
"关闭错误信息响铃"
set noerrorbells

"关闭使用可视响铃代替呼叫"
set novisualbell

"高亮显示匹配的括号([{和}])"
set showmatch

"搜索逐字符高亮"
set hlsearch
set incsearch

"搜索时不区分大小写"
set ignorecase

"用浅色高亮显示当前行"
autocmd InsertLeave * se nocul
autocmd InsertEnter * se cul

"输入的命令显示出来,看的清楚"
set showcmd
set autochdir

"打开界面的大小
set lines=30 columns=120 

3.4.编码设置

" =============================================================
"                     编码设置
" =============================================================
"设置编码"
set encoding=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936,big-5,euc-jp

"设置文件编码"
set fileencodings=utf-8

"设置终端编码"
set termencoding=utf-8

"设置语言编码"
set langmenu=zh_CN.UTF-8
set helplang=cn

3.5.其他设置

" =============================================================
"                           其他设置
" =============================================================
"在处理未保存或只读文件的时候,弹出确认"
set confirm

"显示状态栏(默认值为1,表示无法显示状态栏)"
set laststatus=2

"共享剪切板"
set clipboard+=unnamed

"自动保存"
set autowrite

"关闭vi兼容模式"
set nocompatible
set backspace=indent,eol,start

"设置历史记录步数"
set history=1000

"禁止生成临时文件
set nobackup
set noswapfile

"激活鼠标的使用,(类似office中在工作区双击鼠标定位)
set mouse=a
set selection=exclusive
set selectmode=mouse,key

4.插件配置

4.1.插件管理

" -------------------------插件管理----------------------------
call plug#begin()
Plug 'preservim/NERDTree'        "目录树
Plug 'bling/vim-airline'         "状态栏美化
"Plug 'w0rp/ale'                 "语法检查,需要vim8.0以上
Plug 'scrooloose/syntastic'      "语法检查
Plug 'HonkW93/automatic-verilog' "自动例化
call plug#end()

在终端内打开vim,进入命令模式输入PlugInstall安装插件包

4.2.目录树设置

" -------------------------NERDTree----------------------------
" 目录树窗口尺寸
let g:NERDTreeWinSize = 25

" 忽略以下文件的显示
let NERDTreeIgnore=['\.pyc','\~$','\.swp']

" 显示书签列表
let NERDTreeShowBookmarks=1

" 显示隐藏文件
let NERDTreeShowHidden=1

" 修改默认箭头符号
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'

" vim启动时自动打开NERDTree
augroup NERDTree
    au!
    autocmd vimenter * NERDTree     
    " vim启动打开目录时自动打开NERDTree
    autocmd StdinReadPre * let s:std_in=1
    autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
    autocmd vimenter * NERDTreeFind 
    " 文件全部关闭时退出NERDTree
    autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
augroup END

4.3.状态栏美化

" -------------------------vim-airline----------------------------
" 显示颜色
set t_Co=256
set laststatus=2

" 使用powerline打过补丁的字体
let g:airline_powerline_fonts = 1

4.4.语法检查ALE,需要vim8.0以上

" -------------------------ale----------------------------
"keep the sign gutter open
let g:ale_sign_column_always = 1
let g:ale_sign_error = '>>'
let g:ale_sign_warning = '--'
 
" show errors or warnings in my statusline
" self-define statusline
" use quickfix list instead of the loclist
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 1
" only enable these linters
let g:ale_linters = {    'verilog': ['verilator']}

4.5.语法检查syntastic

" 总是打开Location List(相当于QuickFix)窗口
let g:syntastic_always_populate_loc_list = 1

"不自动进行代码检查
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0

"检查语法的编译器
let g:syntastic_verilog_checkers = ['verilator']

4.6.自动例化--automatic-verilog

文件头自动生成:

always块自定义快捷键:

always块自定义格式以及module框架自动生成:

5.自定义快捷键

" =============================================================
"                         快捷键设置
" =============================================================
"自定义命令前缀,防止冲突
let mapleader=","

"插入模式退出插入模式ii
imap ii <ESC>

"正常模式下保存,w
nmap <Leader>w :w<CR>

"正常模式下保存退出,q
nmap <Leader>q :q<CR>

"正常模式下保存退出,wq
nmap <Leader>wq :wq<CR>

"正常模式下打开关闭文件目录ctrl+t
nmap <C-t> :NERDTreeToggle<CR>

"正常模式下语法检查,ck
nmap <Leader>ck :SyntasticCheck<CR>

"括号自动补全
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap { {<CR>}<ESC>O
:inoremap } <c-r>=ClosePair('}')<CR>
function! ClosePair(char)
    if getline('.')[col('.') - 1] == a:char
        return "\<Right>"
    else
        return a:char
    endif
endfunction

"配对自动补全,按空格自动补全
:ab case; case()<CR><CR><CR>default: ;<CR>endcase<ESC>kkki
:ab begin; begin<CR><CR>end<ESC>ki
:ab reg; <ESC>0i<Tab>reg<Tab><Tab>[NAME_WIDTH-1:0]<Tab><Tab><Tab>reg_name<Tab>; //<CR>
:ab wire; <ESC>0i<Tab>wire<Tab>[NAME_WIDTH-1:0]<Tab><Tab><Tab>wire_name<Tab>; //<CR>
:ab input; <ESC>0i<Tab>input<Tab><Tab>[NAME_WIDTH-1:0]<Tab><Tab><Tab>input_name<Tab><Tab>, //<CR>
:ab output; <ESC>0i<Tab>output reg<Tab>[NAME_WIDTH-1:0]<Tab><Tab><Tab>output_name<Tab><Tab>, //<CR>
:ab para; <ESC>0i<Tab>parameter<Tab>NAME_WIDTH<Tab><Tab>=<Tab><Tab>8<Tab><Tab>, //<CR>
:ab if; if() begin<CR><CR>end<ESC>ki
:ab elif; else if() begin<CR><CR>end<ESC>ki
:ab else; else begin<CR><CR>end<ESC>ki
标签: centos linux vim

本文转载自: https://blog.csdn.net/weixin_61081689/article/details/137017533
版权归原作者 transfer_ICer 所有, 如有侵权,请联系我们删除。

“Verilog编辑器Gvim的配置”的评论:

还没有评论