vim 手册

vimtutor 精简版本
help user-manual 详细手册

一些vim自带设置

直接在~/.vimrc文件上写上如下配置即可

set nu "显示行号
set cursorline "高亮显示当前行
set cursorcolumn "高亮显示当前列
set hlsearch "高亮显示搜索结果 " 自适应不同语言的智能缩进
filetype indent on
" 将制表符扩展为空格
set expandtab
" 设置编辑时制表符占用空格数
set tabstop=4
" 设置格式化时制表符占用空格数
set shiftwidth=4
" 让 vim 把连续数量的空格视为一个制表符
set softtabstop=4

Manjaro下让vim支持clipboard

使用命令vim --version | grep "clipboard"来查看是否支持clipboard,如若看到-clipboard就是不支持,如果看到+clipboard就是支持。

如果是不支持那就使用sudo pacman -S gvim安装gui版本的vim。

复制到系统剪切板的命令是:"+y注意那个加号是真的要输入的+, 粘贴系统剪贴板的命令是shift insert或者ctrl shift v

Windows下让vim支持clipboard

我是使用MSYS2安装的vim:pacman -S vim,安装后vim --version | grep "clipboard"发现直接能看到+clipboard

MSYS2的使用参考另外的文章:https://www.cnblogs.com/feipeng8848/p/10038421.html

Ubuntu

sudo apt install vim-gtk

插件管理 vim-plugin

下载下面的文件:

https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

并将文件放在 windows 中的 ~/vimfiles/autoload 或 unix 中的 ~/.vim/autoload 文件夹内

https://www.v2ex.com/t/532549

安装插件

安装插件,只需要将插件写在 .vimrc 内,然后在 vim 中使用 :PlugInstall 命令即可:

call plug#begin('~/.vim/plugged')
Plug 'vim-airline/vim-airline'
call plug#end()

确保插件要放在 begin 和 end 之间

重新打开 vim 使用命令 :PlugInstall

Finishing ... Done! 表示安装完成

plug-vim的github页面有很多插件的例子可以参考

删除插件

删除插件,只需要将写在 .vimrc 配置文件内的插件删除,重启 vim 并执行命令 :PlugClean 即可:

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

call plug#end()

保存在 vim 中使用 :PlugClean:

设置代码高亮

打开~/.vimrc文件追加一行syntax on 这是默认的vim代码高亮设置,插件的后面再说。

nerdtree插件

用于列出目录树,效果如下图



github 链接:https://github.com/scrooloose/nerdtree

安装:打开~/.vimrc 添加如下命令

call plug#begin('~/.vim/plugged')
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
call plug#end()

然后打开vim输入PluginInstall

配置nerdtree

以下翻译自github帮助文档,直接在~/.vimrc文件中写入配置就行

1、在vim启动时自动打开NERDTree

autocmd vimenter * NERDTree

2、如果没有指定文件,如何在vim启动时自动打开NERDTree?

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

3、如何映射特定键或快捷方式以打开NERDTree?

下面的配置使用control n切换是否打开nerdtree

map <C-n> :NERDTreeToggle<CR>

更多配置可参考github DOC目录下的教程

另外一些常用快捷键

ctrl + w + h 光标 focus 左侧树形目录
ctrl + w + l 光标 focus 右侧文件显示窗口
ctrl + w + w 光标自动在左右侧窗口切换
ctrl + w + r 移动当前窗口的布局位置

我的配置

" NERD tree
let NERDChristmasTree=0
let NERDTreeWinSize=35
let NERDTreeChDirMode=2
let NERDTreeIgnore=['\~$', '\.pyc$', '\.swp$']
let NERDTreeShowBookmarks=1
let NERDTreeWinPos="left"
" 打开vim自动打开nerdtree
autocmd vimenter * NERDTree
" Automatically open a NERDTree if no files where specified
autocmd vimenter * if !argc() | NERDTree | endif
" 自动关闭nerdtree
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"open NERDTree automatically when vim starts up on opening a directory
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
" Open a NERDTree
map <C-n> :NERDTreeToggle<CR>

Molokai 配色方案

下载文件https://github.com/tomasr/molokai,colors放置到.vim文件夹下

.vimrc文件添加:

Plugin 'tomasr/molokai'

编辑.vimrc文件,增加以下配置

"molokai配色方案
colorscheme molokai
let g:molokai_original = 1
set t_Co=256
set background=dark

Vim Powerline

一个显示vim状态栏插件,它能够显示vim模式、操作环境、编码格式、行数/列数等信息。

https://github.com/powerline/powerline

Plugin 'Lokaltog/vim-powerline'

代码缩进树

https://github.com/nathanaelkane/vim-indent-guides

Plugin 'nathanaelkane/vim-indent-guides'

然后进vim PluginInstall

在.vimrc中做一些设置

" 随 vim 自启动
let g:indent_guides_enable_on_vim_startup=1
" 从第二层开始可视化显示缩进
let g:indent_guides_start_level=2
" 色块宽度
let g:indent_guides_guide_size=1
" 快捷键 i 开/关缩进可视化
:nmap <silent> <Leader>i <Plug>IndentGuidesToggle

代码补全

https://github.com/ycm-core/YouCompleteMe

Plug 'ycm-core/YouCompleteMe', { 'do': './install.py' }

在plug-vim中安装之后,插件会出现在 ~/.vim/plugged目录下

编译需要

sudo apt install build-essential cmake python3-dev

然后去编译即可

cd ~/.vim/plugged/YouCompleteMe
python3 install.py --clang-completer

YCM还提供以下附加语言支持选项:(机翻自github 的 readme.md)

C#支持:安装Mono( https://www.mono-project.com/download/stable/#download-lin )并在调用install.py的时候添加--cs-completer 。

去支持:安装Go并--go-completer在调用时 添加install.py。

JavaScript和TypeScript支持:安装Node.js和npm并--ts-completer在调用时添加install.py。

Rust支持:--rust-completer在调用时添加install.py。

如果你的Python解释器比2.7.9老,您还需要 rustup你PATH。

Java支持:安装JDK8(需要版本8)并--java-completer在调用时添加 install.py。

要简单地编译启用的所有内容,就会有一个--all标志。请注意,这个标志也没有安装clangd。您需要通过添加手动指定它--clangd-completer。

因此,安装了所有的语言特性,保证 xbuild,go,tsserver,node,npm和安装工具和你PATH,然后只需运行:

cd ~/.vim/bundle/YouCompleteMe
python3 install.py --all

编译过程中遇到了一些问题找不到文件等。后发现那个目录缺少文件,删除那个目录然后重新执行git submodule update --init --recursive 后解决

错误信息

CMake Error: The source directory "/home/kun/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
ERROR: the build failed. NOTE: it is *highly* unlikely that this is a bug but rather
that this is a problem with the configuration of your system or a missing dependency. Please carefully read CONTRIBUTING.md
and if you're sure that it is a bug, please raise an issue on the issue tracker, including the entire output of this script
and the invocation line used to run it.

解决:



然后再执行python3 install.py --all编译就好了

此时,YCM应该是可以做一些简单的代码补全了,但是,还没有那么好用,比如我装的C#,system.之后没有任何提示。

接下来就是配置了,配置完才好用。

对于c家族语言

用ycm自带的.ycm_extra_conf.py文件.

cp third_party/ycmd/examples/.ycm_extra_conf.py ~/

配置.vimrc文件

let g:ycm_global_ycm_extra_conf='~/.ycm_extra_conf.py'

其他

https://github.com/Lokaltog/vim-powerline 已经不再维护,有新版本,但是需要安装很多东西,Python啥的。

这里用老版本就是上面的链接,在 .vimrc中添加Plugin 'Lokaltog/vim-powerline'后在vim中执行PluginInstall就可以了

vim使用系统的粘贴板

https://www.cnblogs.com/jpfss/p/9040561.html

参考

https://github.com/yangyangwithgnu/use_vim_as_ide

https://saul-mirone.github.io/2017/06/20/vim-config/

http://yuez.me/cong-ling-da-jian-he-pei-zhi-osxkai-fa-huan-jing/

http://yuez.me/jiang-ni-de-vim-da-zao-cheng-qing-qiao-qiang-da-de-ide/

https://blog.csdn.net/zhangpower1993/article/details/52184581

http://www.wklken.me/posts/2015/06/07/vim-plugin-tagbar.html

YouCompleteMe https://vimjc.com/vim-youcompleteme-install.html

YouCompleteMe https://www.jianshu.com/p/d908ce81017a?nomobile=yes

关于vundle : https://zhuanlan.zhihu.com/p/54078065

vim 插件 入门的更多相关文章

  1. 【转载】跟我一起学习VIM - vim插件

    目录 写在前面:Life Changing Editor 什么是VIM 为什么选VIM 为什么选其它 为什么犹豫选择它们 VIM >= SUM(现代编辑器) 如何学习VIM 一秒钟变记事本 VI ...

  2. vim使用入门设置

    分为以下四步. 1,安装vim 2,安装git yum -y install vim git (Fedora/CentOS) /apt-get install vim git (Debian/Ubun ...

  3. 跟我一起学习VIM - vim插件合集

    2016-06-14 15:04 13333人阅读 评论(0) 收藏 举报 分类: Linux(104)  目录(?)[+]  前两天同事让我在小组内部分享一下VIM,于是我花了一点时间写了个简短的教 ...

  4. 常用vim插件的安装、使用和管理

      1.Ctags Ctags工具是用来遍历源代码文件生成tags文件,这些tags文件能被编辑器或者其他工具用来快速查找定位源代码中的符号,入变量名,函数名等.比如,tags文件就是Taglist和 ...

  5. VIM插件攻略

    工欲善其事,必先利其器.一个强大的开发环境可以大大提高工作效率.好吧,我知道这是废话...不过,我想一定有很多跟我一样打算进入Linux平台开发的新手,一开始都为找不到一个像Windows下的VS那样 ...

  6. [Tools] Vim插件管理

    我们在使用插件的时候,都不希望插件安装的很杂乱,它不是一个看不见的黑盒,也为了下次方便在其它地方安装. 由于要方便插件管理,于是有了 Vundle,以下做些介绍: 1. 一个插件管理器, 自己本身也是 ...

  7. Vim插件管理——Vundle

    Vim插件管理--Vundle 都说Vim时程序员写给自己的编辑器,其中的情结可想而知.身为一只程序狗CodingDoge,今天就让我带各位学习Vim的使用. vim因为其庞大而强劲的插件受到无比的推 ...

  8. vim 插件管理

    1 进入自己的vim mkdir ./bundle/vundle 2 在vimrc同级中执行 git clone https://github.com/gmarik/vundle.git ./bund ...

  9. 「个人vim插件+配置」

    2016.10.4 filetype indent on syntax on set nu ai ci si set sw= ts= set autochdir set backspace= colo ...

随机推荐

  1. "数字经济"云安全共测大赛Web-Writeup

    gameapp 这题首先反编译apk,简单看了看代码,主要是有startgame和score两个api,然后用模拟器(手机登不上)安装apk抓了下包,数据经过了rsa加密,所以首先用python实现r ...

  2. mysql CONCAT函数

    有时候我们需要使用coacat函数拼接一些字段的生成一个字符串,比如:select concat(field1,field2,field3)  from xxx: 这时候我们就会的到一个这些字段的值拼 ...

  3. Python 自学笔记(四)

    1.for...in...循环语句 1-1.遍历列表 1-2.遍历字典 1-2-1.遍历字典的键和值 1-2-2.遍历字典的键值(一) 1-2-3.遍历字典的键值(二) 1-2-4.遍历字典的值 1- ...

  4. Linux下批量ping某个网段的脚本

    比如现在需要对192.168.0.0/24网段的ip进行检查,检查哪些ip现在被占用,哪些ip没有被占用,可以通过ping命令来检查,也可以通过nmap接参数来检查 ping命令脚本如下: [root ...

  5. 通过generate解析SQL日志生成xml进行SQL回放

    查看Oracle redo日志来分析SQL执行记录 1)设置Oracle数据字典导出路径参数(可选) shutdown immediatealter system set UTL_FILE_DIR=' ...

  6. 在调试linux的休眠功能时如何打开调试信息开关?

    答:在bootargs中添加参数no_console_suspend即可进行调试

  7. 5G 与 MEC 边缘计算

    目录 文章目录 目录 前言 参考文献 通信网络 核心网演进之路 早古时期 2G 网络架构 3G 网络架构 4G 网络架构 5G 5G 网络的需求 5G 网络架构的设计原则 5G 网络的逻辑架构 5G ...

  8. 将springboot安装成windows服务启动。

    下载Windows Service Wrapper 本文下载了winsw-2.3.0-bin.exe. 新建一个目录aiplatformService 在目录里面新建一个aiplatformServi ...

  9. tmpfs使用完毕导致数据库无法正常工作

    df -h 查看 重新启动服务器就可以了

  10. pcntl_fork()函数说明

    pcntl_fork()函数复制了当前进程的PCB,并向父进程返回了派生子进程的pid,父子进程并行,打印语句的先后完全看系统的调度算法,打印的内容控制则靠pid变量来控制.因为我们知道pcntl_f ...