打造适合本身的vim编辑器方法总结

vim使用方法总结

说明:这是打造适合本身的vim编辑器的进阶方法,关于vim基础知识,请自行百度。也可参考文章末尾推荐blog网址
若是以为本身打造vim编辑器麻烦,能够从github上面克隆一个,推荐:vimplushtml

vim简介

在windows系统下使用vim请下载gVim,linux自带Vimlinux

  • Vim是一个相似于Vi的著名的功能强大、高度可定制的文本编辑器,在Vi的基础上改进和增长了不少特性。 VIM是自由软件。Vim是从 vi 发展出来的一个文本编辑器。代码补完、编译及错误跳转等方便编程的功能特别丰富,在程序员中被普遍使用。简单的来讲, vi 是老式的字处理器,不过功能已经很齐全了,可是仍是有能够进步的地方。 vim 则能够说是程序开发者的一项很好用的工具。

配置Vundle

  • Vundle 是一个很方便的vim插件管理器。Vundle自己也是一个vim插件,只须要在vimrc里面配置号就课方便的安装、更新、删除插件,很是好用。关于其余插件的使用,请自行Google
  • 请确保安装好 vim git 这两个包
  • 若是没有
sudo apt-get install vim git
  • 下载Vundle
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
  • 建立 ~/.vimrc 文件,以通知 Vim 使用新的插件管理器。安装、更新、配置和移除插件须要这个文件。
vim ~/.vimrc
  • 在文件中加入如下内容,以后:wq保存退出
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)
Plugin 'file:///home/gmarik/path/to/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
  • 打开vim,键入命令安装插件,加在.vimrc文件中的全部插件都会自动安装
:PluginInstall
  • 安装完毕以后,键入下列命令,能够删除高速缓存区并关闭窗口
:bdelete
  • 在vim命令行模式下使用Vundele
  • 搜索插件:能够指定插件名搜索,如:PluginSearch taglist (查看编程函数列表)
:PluginSearch
:PluginSearch! (从vimscripts网站刷新本地列表)
  • 更新插件
:PluginUpdate
:PluginInstall! (从新安装全部插件)
  • 卸载插件,首先列出已安装的插件,以后将光标置于插件行上,按下shift+d 组合键。而后编辑./vimrc文件(删除插件入口),最后键入:wq 保存退出。另一种方法,先删除插件入口,在使用命令:PluginClean
:PluginList
:e ~/.vimrc
  • 使用Vundle的帮助文档
:h vundle

配置.vimrc文件

  • 打开.vimrc文件,有两种方式。第一次编辑/.vimrc 新文件,建议使用第二种,用leafpad打开。由于vim不支持从其余地方直接复制内容。须要安装 vim-gnome
sudo vim ~/.vimrc
leafpad ~/.vimrc
  • 补充:安装vim-gnome,
sudo apt-get install vim-gnome

操做方式:都是在normal模式下使用的git

y 表示从vim复制到系统剪切版  
p 表示从外部文件(系统剪切版)粘贴到vim  
d 表示剪切  
gp 粘贴而且移动光标到粘贴内容后,gP同理  
yy 复制一行  
dd 删除一行  
p 在当前光标后粘贴  
P 在当前光标前粘贴
  • 在/.vimrc中添加插件入口,写上入口后,再去vim命令行安装
Plugin 'xxxx'
  • 设置其余,能够参考以下。在/.vimrc文件的最下方,添加命令。
set backspace=2
color desert 

set encoding=utf-8
let &termencoding=&encoding
set fileencodings=utf-8,gbk    "解决中文乱码

set number
syntax on
set cindent
set incsearch       "增量式搜索
set hlsearch        "高亮搜索

更多vim进阶,能够参考以下blog

相关文章
相关标签/搜索