centos vim配置
时间: 2023-06-28 07:05:39 浏览: 118
要在CentOS上配置vim,您需要执行以下步骤:
1. 安装vim:在终端中运行以下命令:
```
sudo yum install vim
```
2. 创建.vimrc文件:在终端中运行以下命令:
```
vi ~/.vimrc
```
3. 配置.vimrc文件:将以下内容复制并粘贴到.vimrc文件中:
```
syntax on
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set smartindent
set number
```
4. 保存并退出文件:按Esc键,然后输入:wq并按Enter键。
现在,您已经成功地在CentOS上配置了vim。
相关问题
centOS vim插件配置
首先,你需要安装vim插件管理器Vundle。可以通过以下命令进行安装:
```
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
```
接着,在你的`~/.vimrc`文件中添加以下内容,用于启用Vundle插件管理器和安装插件:
```
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" Add your plugins here (for example)
Plugin 'scrooloose/nerdtree'
Plugin 'tpope/vim-fugitive'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
```
保存并退出`~/.vimrc`文件,然后打开vim,执行以下命令,安装配置好的插件:
```
:PluginInstall
```
Vundle将自动从GitHub上下载和安装已列出的插件。
至此,你的vim插件配置已完成。
centOS vim插件全套配置
以下是一个基于Vundle插件管理器的完整vim插件配置样例,包含常用插件和快捷键绑定等:
```
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" Add your plugins here
Plugin 'scrooloose/nerdtree' " 文件树
Plugin 'tpope/vim-fugitive' " Git
Plugin 'jiangmiao/auto-pairs' " 自动补全括号
Plugin 'vim-airline/vim-airline' " 状态栏
Plugin 'vim-airline/vim-airline-themes' " 状态栏主题
Plugin 'tpope/vim-surround' " 快捷键快速包围文本
Plugin 'tpope/vim-repeat' " 使 . 命令支持插件操作
Plugin 'tpope/vim-commentary' " 快速注释
Plugin 'preservim/nerdcommenter' " 快速注释
Plugin 'vim-scripts/indentpython.vim' " Python缩进
Plugin 'SirVer/ultisnips' " 代码片段
Plugin 'honza/vim-snippets' " 代码片段
Plugin 'fatih/vim-go' " Golang 工具
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" 定义快捷键
nnoremap <C-n> :NERDTreeToggle<CR> " 打开/关闭文件树
nnoremap <leader>gs :Git<CR> " 打开 Git 窗口
nnoremap <leader>gb :Git blame<CR> " Git blame
nnoremap <leader>gc :Git commit<CR> " Git commit
nnoremap <leader>gd :Gdiff<CR> " Git diff
nnoremap <leader>gl :Glog<CR> " Git log
nnoremap <leader>gp :Git push<CR> " Git push
nnoremap <leader>gs :Gstatus<CR> " Git status
nnoremap <leader>gw :Gwrite<CR> " Git write
" 设置状态栏主题
let g:airline_theme='molokai'
```
保存并退出`~/.vimrc`文件,然后打开vim,执行以下命令,安装配置好的插件:
```
:PluginInstall
```
Vundle将自动从GitHub上下载和安装已列出的插件。
至此,你的vim插件全套配置已完成。
阅读全文