Vim的全面配置

news/2024/7/21 13:34:04 标签: 大数据, ubuntu, vim, 编辑器

最近安了ubuntu 22.04版本的虚拟机,想用于做ROS和docker的爬虫,这次的编辑器我只选择了vim,其中设置颇费了一阵时间。现在就记录一下过程,帮助大家避坑


目录

一、Vim的安装

二、Vim的基础设置

三、Vim插件安装

四、安装自动补全插件youcompleteme

 五、安装主题插件Solarized

六、 安装nerdtree,nerdcommenter与ctrlp

以下是我们安装过的所有插件


ubuntu 22.04版本和20年的版本安装和相关设置方式类似,这里不详解,感兴趣可以移步至:(1条消息) Ubuntu 20.04从安装到配置全套避坑指南_风起鸿庄的博客-CSDN博客_electron-ssr设置

我在这里着重介绍vim的设置

一、Vim的安装

首先在命令行内输入vim,看一下系统有没有自动安装vim,如果已经安装可以跳过这步

如果未安装,输入以下命令:


sudo apt-get install vim vim-scripts vim-doc
#安装vim图形化界面,也可以只用命令行
sudo apt-get install vim-gtk

二、Vim的基础设置

首先进入vimrc配置文件:

sudo vim /etc/vim/vimrc

当进入相关命令行后,敲击i键,进入insert模式

在此地

输入以下内容

 set nu           "在左侧行号                                                
 set tabstop      "tab 长度设置为 4
 set nobackup     "覆盖文件时不备份
 set cursorline   "突出显示当前行
 set ruler        "在右下角显示光标位置的状态行
 set autoindent   "自动缩进

之后按esc退出编辑模式,:wq保存文件修改即可生效

三、Vim插件安装

我们这里需要安装Vundle,它是vim下的一款插件管理器

命令行输入:

sudo apt-get install git
git --version
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

 之后新建一个文件

cd ~
gedit .vimrc

输入以下信息

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()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

按:wq保存设置,后再打开此文件,输入

:PluginInstall

 看到done的字样,即为成功

四、安装自动补全插件youcompleteme

已知我们上面已安装git,还需要安装cmake

sudo apt install cmake

sudo apt-get install cmake-qt-gui

 一定要看路径!否则你会后悔的:)

比如说我就把cmake安装在了youcompleteme的文件夹里,以后万一忘了就不好办了,所以不要学我。

在call vundle#begin和call vundle#end()中间加入

Plugin ‘VundleVim/YouCompleteMe’

 之后打开vim界面,输入:PluginInstall,

这些就是已经安装过的插件了 

输入:exit即可退出 

 五、安装主题插件Solarized

cd ~/.vim/bundle
git clone https://github.com/altercation/vim-colors-solarized.git
#上面这条命令不好使,就换成
git clone git://github.com/altercation/vim-colors-solarized.git

就是http方式和ssh方式换着来

然后在.vimrc文件中的call vundle#begin和call vundle#end()中间加入

Plugin 'altercation/vim-colors-solarized'

在filetype plugin indent on 后面加入 

syntax enable
set background=dark
colorscheme solarized

最终效果为:

如果想设置GUI和终端模式下具有不同的背景,输入

if has('gui_running')
    set background=light
else
    set background=dark
endif

如果想使用终端的颜色,可以输入

let g:solarized_termcolors=256
let g:solarized_termtrans=0

这个是相关的界面 ,当然也可以改回来

六、 安装nerdtree,nerdcommenter与ctrlp

在.vimrc文件中的call vundle#begin和call vundle#end()中间加入

Plugin 'scrooloose/nerdtree'                                                                                                                                                                               
Plugin 'scrooloose/nerdcommenter'
Plugin 'kien/ctrlp.vim'

之后vim内命令输入:PluginInstall

等到底下的done出来,大功告成

以下是我们安装过的所有插件

 


http://www.niftyadmin.cn/n/342042.html

相关文章

机器学习项目实战-能源利用率 Part-3(特征工程与特征筛选)

博主前期相关的博客可见下: 机器学习项目实战-能源利用率 Part-1(数据清洗) 机器学习项目实战-能源利用率 Part-2(探索性数据分析) 这部分进行的特征工程与特征筛选。 三 特征工程与特征筛选 一般情况下我们分两步走…

PCIe 文章总览

文章目录 PCIe 官方资料PCIe简介PCIe 设备MSIlinux irq domainlinux irq domain V1linux irq domain V2 linux PCIe内存枚举msi domain PCIe 官方资料 PCIe书籍Serdes资料PCIe协议栈 PCIe简介 简介 PCIe 设备 PCIe转RS232PCIe转USB3.0 MSI 从linux code 出发的 MSI实例G…

【5.20】五、安全测试——安全测试工具

目录 5.4 常见的安全测试工具 1. Web漏洞扫描工具——AppScan 2. 端口扫描工具——Nmap 3. 抓包工具——Fiddler 4. Web渗透测试工具——Metasploit 小提示:Kali Linux 5.4 常见的安全测试工具 安全测试是一个非常复杂的过程,测试所使用到的工具也…

斯坦福、Nautilus Chain等联合主办的 Hackathon 活动,现已接受报名

由 Stanford Blockchain Accelerator、Zebec Protocol、 Nautilus Chain、Rootz Lab 共同主办的黑客松活动,现已接受优秀项目提交参赛申请。 在加密行业发展早期,密码极客们就始终在对区块链世界基础设施,在发展方向的无限可能性进行探索。而…

AcWing算法提高课-1.3.10混合背包问题

宣传一下算法提高课整理 <— CSDN个人主页&#xff1a;更好的阅读体验 <— 本题链接&#xff08;AcWing&#xff09; 点这里 题目描述 有 N N N 种物品和一个容量是 V V V 的背包。 物品一共有三类&#xff1a; 第一类物品只能用1次&#xff08;01背包&#xff0…

Red Hat Enterprise Linux (RHEL) 8.8 正式版发布

红帽企业 Linux 8.8 发布 Red Hat Enterprise Linux (RHEL) 8.8 (x86_64, aarch64) Release 请访问原文链接&#xff1a;https://sysin.org/blog/rhel-8/&#xff0c;查看最新版。原创作品&#xff0c;转载请保留出处。 作者主页&#xff1a;sysin.org 2023年 5月 16日&…

【SpringCloud组件——Ribbon(负载均衡)】

一、Ribbon主要作用在哪一环节&#xff1f; 流程讲解&#xff1a; 案例依然采用Eureka章节提供的案例&#xff0c;orderService根据服务名称发起请求&#xff0c;请求传达至Ribbon&#xff0c;此时Ribbon从Eureka中心拉取userService服务列表&#xff0c;Ribbon根据负载均衡算法…

Python泰裤辣丨520写一个自动换壁纸软件,将女友照骗放进去送给她

Python泰裤辣!520写一个自动换壁纸软件&#xff0c;将女友照骗放进去送给她! 准备工作1、环境2、使用的模块3、如何配置pycharm里面的python解释器?4、pycharm如何安装插件? 代码实战1、获取壁纸 自动更换壁纸程序最后 话说兄弟们&#xff0c;今天520你们都送给女朋友啥礼物了…