1:用xshell连接虚拟机
xshell是NetSarang开发的一个强大的安全终端模拟软件。使用方便,支持中国字符显示,可以像操作文本编辑器那样直接复制粘贴,而且有免费版。xftp远程上传和下载文件也很好用。
xshell下载链接:https://www.netsarang.com/zh/xshell/
2:安装vim
yum -y install vim*
3:配置.vimrc
在root目录下如果没有.vimrc就新建一个。
复制粘贴以下内容,配置来源https://www.cnblogs.com/smallest/articles/2411918.html
"预防手误
nnoremap : :
cnoremap Q! q!
command Q q
command Wq wq
command WQ wq
"文本格式编排
set nocompatible
filetype on
set encoding=utf-8
set number
syntax on
set confirm
set tabstop=4
set shiftwidth=4
set cindent
set smartindent
set autoindent
set mouse=a
set showmatch
set nohls
set incsearch
"设置= + - * < >前后自动空格
""设置,后面自动添加空格
function! EqualSign(char)
if a:char =~ '=' && getline('.') =~ ".*("
return a:char
endif
let ex1 = getline('.')[col('.') - 3]
let ex2 = getline('.')[col('.') - 2]
if ex1 =~ "[-=+><>\/\*]"
if ex2 !~ "\s"
return "\<ESC>i".a:char."\<SPACE>"
else
return "\<ESC>xa".a:char."\<SPACE>"
endif
else
if ex2 !~ "\s"
return "\<SPACE>".a:char."\<SPACE>\<ESC>a"
else
return a:char."\<SPACE>\<ESC>a"
endif
endif
endif
endfunction
let g:equ=1
if exists("g:equ")
:inoremap = <c-r>=EqualSign('=')<CR>
:inoremap + <c-r>=EqualSign('+')<CR>
:inoremap - <c-r>=EqualSign('-')<CR>
:inoremap * <c-r>=EqualSign('*')<CR>
:inoremap / <c-r>=EqualSign('/')<CR>
:inoremap > <c-r>=EqualSign('>')<CR>
:inoremap < <c-r>=EqualSign('<')<CR>
:inoremap , ,<space>
endif
set mouse=a是在vim所有模式中使用鼠标,此时鼠标右键无效了,可用鼠标中键实现粘贴功能。
4:安装ctag和taglist
yum -y install ctags
在windows从https://www.cnblogs.com/feichexia/archive/2012/11/05/vim2_taglist.html下载taglist插件
并解压,将解压后得到的doc和plugin复制到虚拟机设置的共享文件夹中,或者通过xftp工具上传到虚拟机中。
在用户的根目录(我用的是root目录)中建立 .vim目录,并将doc和plugin复制到.vim 中。
mkdir /root/.vim
cp -r /root/win/share/doc /root/.vim/
cp -r /root/win/share/plugin /root/.vim/
在vim底行模式下输入Tlist即可开启Tlist
5:关于taglist的配置
在.vimrc中加入以下几行
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=1
let Tlist_Auto_Open=1
let Tlist_File_Fold_Auto_Close=1