[转载] ubuntu下定制Vim/Gvim及使用技巧
vim是linux下的编辑器之神,是玩linux的必备工具,同样emacs是神的编辑器,两个编辑器是各有千秋,看个人的喜好,青菜萝卜各有所爱。我是比较喜欢vim,用vim编写bash,perl,python脚本,以及修改配置文件等等,本文就主要介绍在Ubuntu下gvim环境的搭建,希望对大家有所帮助。
一. Ubuntu安装gvim方法
安装gvim的方法,最简单方法是在Ubuntu软件中心搜索gvim,然后点击安装即可,如下图:
如果使用命令行可以打开终端,输入sudo apt-get install vim-gtk vim-doc cscope
二. 安装gvim常用插件
安装好gvim后就可以使用了,不过在用gvim编写代码的时候还是有点小不方便,比如代码的颜色高亮,自动补全,自动添加相关函数注释,工程管理等等。这些都不必担忧,gvim有很多的插件可以满足上面的功能,甚至更多,下面我安装的是我常用的一些插件。
Gvim插件可以到下面的网址自行选择喜欢的插件: http://www.vim.org/scripts/script_search_results.php?order_by=downloads
taglist.vim插件:该插件是查看源代码的结构等,支持C/C++,java,php等多种语言。
安装方法:
下载taglist.zip,解压到$HOME/.vim目录中;
进入$home/.vim/doc目录下,运行vim,输入:help tags,启用taglist的帮助文档;
重启gvim,运行:TlistToggle启用taglist
具体步骤:
创建$HOME/.vim目录
-pc:~$ mkdir .vim
下载并解压到.vim目录中
- -pc:~$ cd .vim/
- -pc:~/.vim$ unzip /home/test/下载/taglist_45.zip
- Archive: /home/test/下载/taglist_45.zip
- inflating: plugin/taglist.vim
- inflating: doc/taglist.txt
进入到doc目录,并运行vim
- -pc:~/.vim$ cd doc/
- -pc:~/.vim/doc$ vim

supertab插件:
安装步骤:
1. 下载该插件,下载地址:
http://www.vim.org/scripts/script.php?script_id=1643
2.用vim打开supertab.vba文件,并使之生效:so %,如图:



perl-support.vim插件:
安装方法:
下载插件,下载地址:
http://www.vim.org/scripts/script.php?script_id=556
将perl-support.zip解压到$HOME/.vim目录下
- -pc:~/.vim$ unzip /home/linuxpc/下载/perl-support.zip
- Archive: /home/linuxpc/下载/perl-support.zip
- inflating: doc/perlsupport.txt
- inflating: README.perlsupport
- creating: ftplugin/
- inflating: ftplugin/pod.vim
- inflating: ftplugin/perl.vim
- creating: autoload/
- inflating: autoload/perlsupportregex.vim
- inflating: autoload/perlsupportgui.vim
- inflating: autoload/perlsupportprofiling.vim
- inflating: plugin/perl-support.vim
- creating: perl-support/
- creating: perl-support/modules/
- inflating: perl-support/modules/perl-modules.list
- creating: perl-support/templates/
- inflating: perl-support/templates/Templates
- inflating: perl-support/templates/idioms.template


bash-support.vim插件
与perl-support类似的一款插件,bash-support.vim插件,这两个插件的功能类似
安装步骤:
下载插件,并解压到$HOME/.vim目录中
下载地址:
解压到目录下:
- -pc:~/.vim$ unzip /home/waydeechen/下载/bash-support.zip
- Archive: /home/waydeechen/下载/bash-support.zip
- inflating: README.bashsupport
- inflating: doc/bashsupport.txt
- inflating: ftplugin/sh.vim
- creating: bash-support/
- creating: bash-support/templates/
- inflating: bash-support/templates/Templates
- inflating: bash-support/templates/bash.paramsub.template
- inflating: bash-support/templates/bash.statements.template
- inflating: bash-support/templates/bash.comments.template
- creating: bash-support/codesnippets/
- inflating: bash-support/codesnippets/timestamp


AutoComplPop插件
AutoComplPop可以打开自动补全的窗口,不单单可以补全变量函数等,还可以补全文件名。
下载地址:http://www.vim.org/scripts/script.php?script_id=1879
安装方法很简单,将下载的文件解压到$HOME/.vim目录中
使用效果图:

最后晒下自己的.vimrc文件:
- set backspace=indent,eol,start
- set history=50 " keep 50 lines of command line history
- set ruler " show the cursor position all the time
- set showcmd " display incomplete commands
- set incsearch " do incremental searching
- set number
- syntax on “打开语法高亮
- set autoindent “自动缩进
- set smartindent “使用c形式自动缩进
- set cindent
- set tabstop=4 “TAB键的宽度
- set shiftwidth=4 “统一缩进为4
- set showmatch “高亮显示匹配括号
- set incsearch
- set nu “显示行号
- color darkblue ”颜色方案
- set ruler
- set ignorecase “搜索忽略大小写
- set smartcase
- set hlsearch ”设置搜索字符高亮
- set report=0
- set mouse=a
- set nobackup
- set noeb
- set history=1000
- set nobackup
- set noswapfile
- set enc=utf-8 ”语言编码设置
- set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936
- set langmenu=ZH_CN.UTF-8
- set helplang=cn
- set laststatus=2
- set ruler “显示光标位置状态行
- set cmdheight=1 ”设置命令行的高度
- filetype on “侦测文件类型
- filetype plugin on ”载入文件类型插件
- filetype indent on
- set viminfo+=! “保存全局变量
- set iskeyword+=_,$,@,%,#,- ”带有这些字符的单词不要被换行分割
- set linespace=0 “字符间插入像素行数目
- set wildmenu ”命令行自动完成操作
- set backspace=2 “使用回格键
- set whichwrap+=<,>,h,l ”允许backspace和光标跨越行
- set selection=exclusive
- set selectmode=mouse,key
vim常用使用方法:
:e:打开文件,例::e /opt/shell/status.sh
ZZ: 关闭文件
vim +18 /opt/status.sh :打开status.sh并跳到第18行
- vim +18 /opt/status.sh :打开status.sh并跳到第18行
- 13
- 14 ########## DEFINE FUNCTIONS ##########
- 15
- 16 function in_range_random_number()
- 17 {
- 18 #create a random number which is less than or equal to UPPER_LIMIT
- 19 RANDOM_NUMBER=$(( $RANDOM % $UPPER_LIMIT + 1 ))
- 20 echo -e "$RANDOM_NUMBER"
- 21 }
- 14 ########## DEFINE FUNCTIONS ##########
- 15
- 16 function in_range_random_number()
- 17 {
- 18 #create a random number which is less than or equal to UPPER_LIMIT
- 19 RANDOM_NUMBER=$(( $RANDOM % $UPPER_LIMIT + 1 ))
- 20 echo -e "$RANDOM_NUMBER"
- 21 }
- 22
vim +/RANDOM_NUMBER /opt/shell/random_passwd_create.sh:打开脚本并从头开始查询,到第一个匹配模式的地方
vim +?RANDOM_NUMBER /opt/shell/random_passwd_create.sh 从文件尾搜索
- vim +/^# /opt/shell/random_passwd_create.sh
- 160
- 161 ########## start of main ##########
- 162
- 163 trap `trap_exit;exit 2` 1 2 3 15
- 164
- 165 check_for_and_create_keyboard_file
7. 将文件部分写入另一个文件
- :5,15w /tmp/hshhs
8. 删除空行
- :g/^$/d
9. vimdiff 命令

10.vimgrep命令

更多Ubuntu相关信息见Ubuntu 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=2
[转载] ubuntu下定制Vim/Gvim及使用技巧的更多相关文章
- Ubuntu下更改Vim配置文件打造C/C++风格
转载:Ubuntu下更改Vim配置文件打造C/C++风格 Vim默认的配置使用起来还不能让人满意,还需要自己配置 默认配置文件是:/etc/vim/vimrc我们可以在家目录下建立自己的配置文件切换到 ...
- ubuntu 下安装 VIM 依赖vim-common错误
ubuntu 下安装 VIM 依赖vim-common错误 sudo apt-get remove vim-common 先把上面的错误依赖删除 sudo apt-get install vim ...
- (转载)Ubuntu下安装Qt
转载自:http://blog.csdn.net/timidsmile/article/details/7716201 Ubuntu下安装Qt 1: sudo apt-get install qt4- ...
- Ubuntu下终端Vim编写C语言程序 AAAAA
我是开虚拟机下的Ubuntu,装双系统又卸了,Ubuntu默认是不包含编辑器vim和编译器gcc.如果你是刚安装好的Ubuntu电脑,下面我们将来实现自己的第一个程序. 1.准备工作 首先进入root ...
- [转载]Ubuntu下apache的安装与配置
原文地址:https://blog.csdn.net/gatieme/article/details/53025505 1 安装apache 在 Ubuntu 上安装 Apache,有两种方式 使用源 ...
- [转载]--Ubuntu下修改DNS重启也能用的方法
安装好Ubuntu之后设置了静态IP地址,再重启后就无法解析域名.想重新设置一下DNS,打开/etc/resolv.conf cat /etc/resolv.conf# Dynamic resolv. ...
- [转载]Ubuntu下Git服务器安装与配置
原文地址:Ubuntu下Git服务器安装与配置作者:F民抄 1. 安装 1.1 安装Git-Core: sudo apt-get install git-core 1.2 安装 Gitosis sud ...
- Ubuntu下将vim配置为Python IDE(转)
工欲善其事,必先利其器. 配置好了Django的环境,该把vim好好配置一下当做python的IDE来用. 在Windows下用惯了各种现成的工具,转到Linux下,一下没了头绪……好歹google出 ...
- Ubuntu 下一个 vim 建立python 周围环境 构造
于Windows通过使用各种现成的工具使用,去Linux下一个,没有一个关于线索--总之google有些人的经验,折腾来折腾,开发环境也算是一个好工作. 1. 安装完成vim # apt-get in ...
随机推荐
- 传说中的WCF(8):玩转消息协定
Message翻译成中文,相信各位不陌生,是啊,就是消息,在WCF中也有消息这玩意儿,不知道你怎么去理解它.反正俺的理解,就像我们互发短信一个道理,通讯的双方就是服务器与客户端,说白了吧,就是二者之间 ...
- volatile 关键字的复习
今天早上看何登成的微博(http://hedengcheng.com/?p=725) 对volatile 关键字语意进行了深入分析. 看完之后,用自己的话总结如下: 1.c/c++ volatile中 ...
- SQLHelper.cs的经典代码-存储过程
using System; using System.Collections.Generic; using System.Text; using System.Collections; using S ...
- Java科普之算法剖析
本文来自http://blog.csdn.net/liuxian13183/ ,引用必须注明出处! 从小白晋升,一路走来:从helloworld,到JFrame,再到Android:从城外小子,到内城 ...
- 286. Walls and Gates
题目: You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or an ob ...
- Scala模式匹配和类型系统
1.模式匹配比java中的switch case强大很多,除了值,类型,集合等进行匹配,最常见的Case class进行匹配,Master.scala有大量的模式匹配. Case "_&qu ...
- istream, outstream使用及常见错误
使用方法: 使用filebuf打开文件,并拷贝给istream/ostream. 如下面的例子中,实现读取并处理deseq文件夹下所有文件,输出到ostream fw. code: #include& ...
- storage size of ‘oldact’ isn’t known
#include <signal.h> int main(){struct sigaction act, oldact;return 0;} dies with the message t ...
- 10位IT领袖给应届毕业生的10条忠告
10位IT领袖给应届毕业生的10条忠告,在走向独立和自主的伟大征程中,吸取他们的经验. 在毕业生们迈出象牙塔之时,他们应该听从哪些人的建议?在走向独立和自主的伟大征程中,他们该吸取哪些教训?听一听各领 ...
- Javascript performance
I just went through some vedio related to javascript performance which is great, Here is the notes I ...