linux虚拟机怎么使用vim,Linux虚拟机中vim的配置

本文介绍了如何在Linux虚拟机上安装和配置vim编辑器,包括安装vim相关软件包,创建并配置.vimrc文件以实现显示行号、自动对齐等功能,以及设置与Windows共享剪贴板、语法高亮等高级特性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

第一步:

Vim安装:首先将命令窗口切换成超用户,然后在命令窗口输入yum install vim命令进入vim相关软件的下载

e8fe6ff038f36e8d24c94e3856c4faab.png

7f2e4c09267f742c1f277757a759c558.png

在命令窗口输入# rpm -qa |grep vim查看vim相关软件包是否已安装

需安装的vim相关软件:

vim-enhanced-7.2.411-1.4.el6.x86_64

vim-common-7.2.411-1.4.el6.x86_64

vim-minimal-7.2.411-1.4.el6.x86_64

vim-X11-7.2.411-1.4.el6.x86_64

dd08a9554cbfda07e4d7db597bad7074.png

第二步:

配置vim,在超用户下touch一个.vimrc文件,然后ls -a查看文件是否建立成功

06c77706c16ca6f1416d299c512ec42f.png

在命令窗口输入vim  .vimrc,进入配置窗口,输入以下配置,并保存

2be14891526bb4b180002fce85cb1f86.png

在配置窗口输入以下配置:

set number                          显示行号set autoindent                     自动对齐set smartindent                   智能对齐set showmatch                    括号匹配模式set ruler                               显示状态行set incsearch                       搜索时一边输入一边显示效果set tabstop=4                       tab键为4个空格set shiftwidth=4缩进空格数为4set cindent                           C语言格式对齐set nobackup                       不要备份文件set clipboard+=unnamed     与windows共享剪贴板syntax on                             语法高亮

set mouse=a                         鼠标支持

set helplang=cn

set encoding=utf-8

set cscopequickfix=s-,c-,d-,i-,t-,e-

nmap s :cs find s =expand("")

nmap g :cs find g =expand("")

nmap c :cs find c =expand("")

nmap t :cs find t =expand("")

nmap e :cs find e =expand("")

nmap f :cs find f =expand("")

nmap i :cs find i ^=expand("")$

nmap d :cs find d =expand("")

let g:miniBufExplMapCTabSwitchBufs = 1

let g:miniBufExplMapWindowNavVim = 1

let g:miniBufExplMapWindowNavArrows = 1

nnoremap :A

nnoremap :Grep

let g:SuperTabRetainCompletionType=2

let g:SuperTabDefaultCompletionType=""

" 自动语法高亮

syntax on

" 检测文件类型

filetype on

" 检测文件类型插件

filetype plugin on

" 不设定在插入状态无法用退格键和 Delete 键删除回车符

set backspace=indent,eol,start

set whichwrap+=,h,l

" 显示行号

set number

" 上下可视行数

set scrolloff=6

" replace tab with space

set expandtab

" 设定 tab 长度为 4

set tabstop=4

" 设置按BackSpace的时候可以一次删除掉4个空格

set softtabstop=4

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

set shiftwidth=4

set smarttab

set history=1024

" 不突出显示当前行

set nocursorline

" 覆盖文件时不备份

set nobackup

" 自动切换当前目录为当前文件所在的目录

set autochdir

" 搜索时忽略大小写,但在有一个或以上大写字母时仍大小写敏感

set ignorecase

set smartcase

" 搜索到文件两端时不重新搜索

set nowrapscan

" 实时搜索

set incsearch

" 搜索时高亮显示被找到的文本

set hlsearch

" 关闭错误声音

set noerrorbells

set novisualbell

"set t_vb=

" 不自动换行

"set nowrap

"How many tenths of a second to blink

set mat=2

" 允许在有未保存的修改时切换缓冲区,此时的修改由 vim 负责保存

set hidden

" 智能自动缩进

set smartindent

" 设定命令行的行数为 1

set cmdheight=1

" 显示状态栏 (默认值为 1, 无法显示状态栏)

set laststatus=2

"显示括号配对情况

set showmatch

" 解决自动换行格式下, 如高度在折行之后超过窗口高度结果这一行看不到的问题

set display=lastline

" 设定配色方案

colorscheme evening

" 设置在状态行显示的信息

set statusline=\ %

" 显示Tab符

set list

set listchars=tab:\|\ ,trail:.,extends:>,precedes:<

"启动时不显示 捐赠提示

set shortmess=atl

"blank      空白

"buffers    缓冲区

"curdir     当前目录

"folds      折叠

"help       帮助

"options    选项

"tabpages   选项卡

"winsize    窗口大小

"slash      转换文件路径中的\为/以使session文件兼容unix

"unix       设置session文件中的换行模式为unix

set sessionoptions=blank,buffers,curdir,folds,help,options,tabpages,winsize,slash,unix,resize

" 允许backspace和光标键跨越行边界

set whichwrap+=,h,l

" backspace

set backspace=eol,start,indent

" 可以在buffer的任何地方使用鼠标(类似office中在工作区双击鼠标定位)

set mouse=a

set selection=exclusive

set selectmode=mouse,key

" 在被分割的窗口间显示空白,便于阅读

set fillchars=vert:\ ,stl:\ ,stlnc:\

" 高亮显示匹配的括号

set showmatch

" 匹配括号高亮的时间(单位是十分之一秒)

set matchtime=5

"编码设置

set enc=utf-8

set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936

" set mapleader

let mapleader=","

nmap J 5j

nmap K 5k

" Ctrl+a

nmap ggvG$

" 选中状态下 Ctrl+c 复制

vnoremap "+y

" Ctrl+v

nmap "+p

" 窗口切换

nnoremap h

nnoremap l

nnoremap j

nnoremap k

" 插入模式下上下左右移动光标

inoremap

inoremap

inoremap gj

inoremap gk

" Ctrl+s

" If the current buffer has never been saved, it will have no name,

" call the file browser to save it, otherwise just save it.

"nnoremap :if expand("%") == ""browse confirm welseconfirm wendif

"imap

" Use CTRL-S for saving, also in Insert mode

nmap :update

vmap :update

imap :update

" C++的编译和运行

"map :call CompileRunGpp()

"func! CompileRunGpp()

"exec "w"

"exec "!g++ % -o %

"exec "! ./%

"endfunc

map :call RunGpp()

func! RunGpp()

exec "w"

exec "! ./%

endfunc

"vim plugin setting

"======================"

set tags=tags

set tags+=~/.vim/my-tags/tags

set tags+=~/.vim/my-tags/stl-tags

set tags+=~/.vim/my-tags/sys-tags

set autochdir

"Update ctags

map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q

""""""""""""""""""""""""""""""

" Tag list (ctags)

""""""""""""""""""""""""""""""

"if MySys() == "windows"                "设定windows系统中ctags程序的位置

"   let Tlist_Ctags_Cmd = 'ctags'

"elseif MySys() == "linux"              "设定Linux系统中ctags程序的位置

let Tlist_Ctags_Cmd = '/home/sphinx/.vim/ctags-5.8/ctags'

"endif

let Tlist_Show_One_File = 1            "不同时显示多个文件的tag,只显示当前文件的

let Tlist_Exit_OnlyWindow = 1          "如果taglist窗口是最后一个窗口,则退出vim

let Tlist_Use_Right_Window = 0         "在右侧窗口中显示taglist窗口

let Tlist_OnlyWindow=1

"let Tlist_Use_Right_Window=0

"let Tlist_Sort_Type='name'

"let Tlist_Show_Menu=1

"let Tlist_Max_Submenu_Items=10

"let Tlist_Max_Tag_length=16     "20

"let Tlist_Use_SingleClick=0

"let Tlist_Auto_Open=0

"let Tlist_Close_On_Select=0

"let Tlist_File_Fold_Auto_Close=1

"let Tlist_GainFocus_On_ToggleOpen=0

"let Tlist_Process_File_Always=1

"let Tlist_WinHeight=10

"let Tlist_WinWidth=18

"let Tlist_Use_Horiz_Window=0

let Tlist_Auto_Highlight_Tag = 1

"let Tlist_Auto_Open = 1

let Tlist_Auto_Update = 1

let Tlist_Close_On_Select = 0

let Tlist_Compact_Format = 0

let Tlist_Display_Prototype = 0

let Tlist_Display_Tag_Scope = 1

let Tlist_Enable_Fold_Column = 0

let Tlist_File_Fold_Auto_Close = 0

let Tlist_GainFocus_On_ToggleOpen = 1

let Tlist_Hightlight_Tag_On_BufEnter = 1

let Tlist_Inc_Winwidth = 0

let Tlist_Max_Submenu_Items = 1

let Tlist_Max_Tag_Length = 30

let Tlist_Process_File_Always = 0

let Tlist_Show_Menu = 0

let Tlist_Sort_Type = "order"

let Tlist_Use_Horiz_Window = 0

let Tlist_WinWidth = 31

map :TlistOpen

"OMNI

"omnicppcoplete

"-- omnicppcomplete setting --

set completeopt=menu,menuone

let OmniCpp_MayCompleteDot = 1

" autocomplete with .

let OmniCpp_MayCompleteArrow = 1

" autocomplete with ->

let OmniCpp_MayCompleteScope = 1

" autocomplete with ::

let OmniCpp_SelectFirstItem = 2

" select first item (but don't insert)

let OmniCpp_NamespaceSearch = 2

" search namespaces in this and included files

let OmniCpp_ShowPrototypeInAbbr = 1

" show function prototype in popup window

let OmniCpp_GlobalScopeSearch=1

let OmniCpp_DisplayMode=1

let OmniCpp_DefaultNamespaces=["std"]

set nocp

filetype plugin on

"WinManager

let g:winManagerWindowLayout='FileExplorer|TagList'

"let g:winManagerWindowLayout='FileExplorer|BufExplorer|TagList'

let g:persistentBehaviour=0

let g:winManagerWidth=20

let g:defaultExplorer=1

nmap wm :WMToggle

"QuickFix

nmap :cn

nmap :cp

"MiniBufExplorer

"let g:miniBufExplMapWindowNavVim = 1

"let g:miniBufExplMapWindowNavArrows = 1

let g:miniBufExplModSelTarget = 1

let g:miniBufExplorerMoreThanOne = 2

let g:miniBufExplModSelTarget = 0

let g:miniBufExplUseSingleClick = 1

let g:miniBufExplMapWindowNavVim = 1

let g:miniBufExplVSplit = 15    "25

let g:miniBufExplSplitBelow=1

let g:bufExplorerSortBy = "name"

autocmd BufRead,BufNew :call UMiniBufExplorer

map u :TMiniBufExplorer

"AutoClose

"let g:AutoClosePairs = {'(': ')', '{': '}', '[': ']', '"': '"', "'": "'"}

let g:AutoClosePairs = {'(': ')', '{': '}', '[': ']', '"': '"', "'": "'"}

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"   Maintainer:

"   "       Geek SphinX

"   "       topcodersphinx@gmail.com

"   "

"   "   Version:

"   "       1.0 - Thu Nov  1 17:21:44 CST 2012

"   "

"   """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" Sets how many lines of history VIM has to remember

" set history=1024

"

" " Auto syntax highlight

" set syntax=on

"

" " Check file format

" filetype on

"

" " Enable filetype plugins

" filetype plugin on

" filetype indent on

"

" " Sets non VI compatible mode

" set nocompatible

"

" " Set to auto read when a file is changed from the outside

" set autoread

"

" " With a map leader it's possible to do extra key combinations

" " like w saves the current file

" let mapleader = ","

" let g:mapleader = ","

"

" " Fast saving

" nmap w :w

" nmap q :q

"

" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" " => VIM user interface

" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" " Replace J, K

" nmap J 5j

" nmap K 5k

"

" " Ctrl+A to select all content in visual mode

" nmap ggvG$

"

" " Ctrl+C to copy

" vnoremap "+y

"

" " Ctrl+V to paste

" nmap "+p

"

" " Set 7 lines to the cursor - when moving vertically using j/k

" set so=7

"

" " Turn on the Wild menu

" set wildmenu

"

" " Ignore compiled files

" set wildignore=*.o,*~,*.pyc

"

" "Always show current position

" set ruler

"

" " Height of the command bar

" set cmdheight=2

"

" " A buffer becomes hidden when it is abandoned

" set hid

"

" " Configure backspace so it acts as it should act

" set whichwrap+=

" set backspace=indent,eol,start

"

" " Ignore case when searching

" set ignorecase

"

" " When searching try to be smart about cases

" set smartcase

"

" " Highlight search results

" set hlsearch

"

" " Makes search act like search in modern browsers

" set incsearch

"

" " Don't redraw while executing macros (good performance config)

" set lazyredraw

"

" " For regular expressions turn magic on

" set magic

"

" " Show matching brackets when text indicator is over them

" set showmatch

"

" " How many tenths of a second to blink when matching brackets

" set mat=2

"

" " No annoying sound on errors set noerrorbells

" set novisualbell

" set t_vb=

" set tm=500

"

" " Show line number

" set number

"

" " Highlight over 80 columns

" highlight OverLength ctermbg=red ctermfg=white guibg=#592929

" match OverLength /\%81v.\+/

"

" " Show Tab symbol

" set list

" set listchars=tab:\|\ ,trail:.,extends:>,precedes:<

"

" " Switch windows

" nnoremap h

" nnoremap l

" nnoremap j

" nnoremap k

"

" " Move cursor in insert mode

" inoremap h

" inoremap l

" inoremap j

" inoremap k

"

"

" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" " => Colors and Fonts

" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" " Enable syntax highlighting

" syntax enable

"

" "colorscheme desert

" colorscheme molokai

" set background=dark

"

" " Set extra options when running in GUI mode

" if has("gui_running")

"     set guioptions-=T

"         set guioptions+=e

"             set t_Co=256

"                 set guitablabel=%M\ %t

"                 endif

"

"                 " Set utf8 as standard encoding and en_US as the standard

"                 language

"                 set encoding=utf8

"

"                 " Use Unix as the standard file type

"                 set ffs=unix,dos,mac

"

"                 " Use Inconsolata as the gui font

"                 set guifont=Inconsolata\ 15

"

"                 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" => Text, tab and indent related

" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" " Use spaces instead of tabs

" set expandtab

"

" " Be smart when using tabs ;)

" set smarttab

"

" " 1 tab == 4 spaces

" set shiftwidth=4

" set tabstop=4

"

" " Linebreak on 500 characters

" set lbr

" set tw=500

"

" set ai "Auto indent

" set si "Smart indent

" set wrap "Wrap lines

"

"

" """"""""""""""""""""""""""""""

" " => Status line

" """"""""""""""""""""""""""""""

" " Always show the status line

" set laststatus=2

"

" " Format the status line

" "set statusline=\ %{HasPaste()}%F%m%r%h\ %w\ \ CWD:\ %r%{getcwd()}%h\ \ \

" Line:\ %l

"

"

" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" " => Mouse

" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" set mouse=a

" set selection=exclusive

" set selectmode=mouse,key

"

" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" " => Plugins

" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

g++/gdb/ctags的配置:

g++的配置

在命令窗口输入yum install gcc-c++

gdb的配置

在命令窗口输入yum install gdb

卸载原有GDB

1. 查询 gdb是否安装

[root@test01~]# rpm -qa |grep gdb

gdb-7.0.1-37.el5_7.1

gdbm-1.8.0-26.2.1

2. 删除包

rpm-e --nodeps gdb-7.0.1-37.el5_7.1

ctags的配置

在命令窗口输入yum install ctags

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值