Vim 配置以及插件管理

本文介绍了如何进行Vim的基本配置,包括创建用户目录下的配置文件,并展示了部分配置内容。接着,文章推荐了一款适合新手的插件管理器,并详细说明了因下载问题而采用的安装方法。最后,讨论了如何安装插件和主题,提供了安装插件的命令以及个人使用的主题配置。

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

Vim 配置以及插件管理

基本vim配置

在用户目录下新建.vimrc文件

cd ~
gedit .vimrc

我的基本配置如下:

部分来源于sources以及关于光标配置这里

 let mapleader = ","  
 nnoremap <silent> <leader>n :NERDTreeToggle<CR>


"sources: http://www.ruanyifeng.com/blog/2018/09/vimrc.html:
set number  
set nocompatible
syntax on
set showmode
set showcmd
set mouse=a
set encoding=utf-8
set t_Co=256
filetype indent on

set autoindent
set tabstop=4
set shiftwidth=4

set expandtab

" cursor setting sources: https://zhuanlan.zhihu.com/p/24898976
" https://vim.fandom.com/wiki/Configuring_the_cursor
set cursorline cursorcolumn
set guicursor=n-v-c:block-Cursor
set guicursor+=n-v-c:blinkon0

set textwidth=80

set wrap
set linebreak

set scrolloff=5
set sidescrolloff=15
set laststatus=2

set ruler

set showmatch
set hlsearch
set incsearch
set ignorecase
set smartcase

set spell spelllang=en_us
set noswapfile
set undofile

set backupdir=~/.vim/.backup//
set directory=~/.vim/.swp//
set undodir=~/.vim/.undo//

set history=2000

set autoread
set wildmenu
set wildmode=longest:list,full

安装vim 插件管理器

我使用的是vim-plug这款适合新手的插件管理器

安装方式:

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https:/r/raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

这是官方文档给出的安装方式,不知道为什么,我用curl下载始终下不下来

在这里插入图片描述

所以只能通过这种方式下载了下载了:

Download plug.vim and put it in the “autoload” directory.

git clone https://github.com/junegunn/vim-plug.git
cp vim-plug/plug.vim ~/.vim/autoload/

安装插件和主题

.vimrc中插入如下命令

call plug#begin('~/.vim/plugged')

call plug#end()

中间放入需要下载的插件,一下是我下载的插件

call plug#begin('~/.vim/plugged')

" Make sure you use single quotes

" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
Plug 'junegunn/vim-easy-align'

" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'

" Multiple Plug commands can be written in a single line using | separators
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'

" On-demand loading
Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }

" Using a non-master branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }

" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
Plug 'fatih/vim-go', { 'tag': '*' }

" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }

" colorscheme
Plug 'rakr/vim-one'
Plug 'hzchirs/vim-material'
Plug 'rakr/vim-two-firewatch'

Plug 'scrooloose/nerdtree'
Plug 'mhinz/vim-startify'
 
" Initialize plugin system
call plug#end()

进入到vim界面,normal 模式下输入:PlugInstall

在这里插入图片描述

等待插件工具下载完成。

及下来是我的主题配置

""""""""""""""""""""""""Color theme"""""""""""""""""""""""""""""""""""
"""""""""""vim-material
" Dark
syntax enable
"set background=dark
"colorscheme vim-material

" Palenight
"let g:material_style='palenight'
"set background=dark
"colorscheme vim-material

""""""""""""""vim-one
"colorscheme one
"set background=dark " for the dark version
"set background=light " for the light version

"let g:one_allow_italics = 1 " I love italic for comments

""""""""""""""vim-two-firewatch
set background=light" or light if you prefer the light version
let g:two_firewatch_italics=1
colo two-firewatch

"let g:airline_theme='twofirewatch' " if you have Airline installed and want the associated theme

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值