红联Linux门户
Linux帮助

vim开发配置,函数颜色格式设置

发布时间:2015-06-19 15:17:42来源:blog.csdn.net/wanlanjian作者:wanlanjian

给自己电脑安装了Ubuntu系统,以后坚持使用linux系统,坚持使用VIM做开发工具。

为了记录VIM使用做如下记录:


1,使用笔记本,安装Ubuntu15.04,系统不自带VIM只有VI,果断安装之。

命令:sudo apt-get install vim


2,进入vi编辑文本后,发现backspace不能用,方向键错乱。解决方法:

vi /etc/vim/vimrc.tiny

原配置为:

set compatible

将配置改为如下:

set nocompatible
set backspace=2


3,刚开始使用VIM做开发特别不适应全黑白色,看的太蛋疼。配置自己的vim方法:

vi ~/.vimrc

插入配置信息如下

" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just 
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime 
" you can find below.  If you wish to change any of those settings, you should 
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten 
" everytime an upgrade of the vim packages is performed.  It is recommended to 
" make changes after sourcing debian.vim since it alters the value of the 
" 'compatible' option. 
" This line should not be removed as it ensures that various options are 
" properly set to work with the Vim-related packages available in Debian. 
runtime! debian.vim 
" Uncomment the next line to make Vim more Vi-compatible 
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous 
" options, so any other options should be set AFTER setting 'compatible'. 
"set compatible 
" Vim5 and later versions support syntax highlighting. Uncommenting the next 
" line enables syntax highlighting by default. 
 
"新建.c,.h,.sh,.java文件,自动插入文件头  
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java exec ":call SetTitle()"  
""定义函数SetTitle,自动插入文件头  
func SetTitle()  
"如果文件类型为.sh文件  
if &filetype == 'sh'  
call setline(1,"\##############################################")  
call append(line("."), "\# File Name: ".expand("%"))  
call append(line(".")+1, "\# Author: Leo ")  
call append(line(".")+2, "\# mail: kuling729@gmail.com")  
call append(line(".")+3, "\# Created Time: ".strftime("%c"))  
call append(line(".")+4, "\######################################")  
call append(line(".")+5, "\#!/bin/bash")  
call append(line(".")+6, "")  
else  
call setline(1, "/******************************************************")  
call append(line("."), "> File Name: ".expand("%"))  
call append(line(".")+1, "> Author: Leo")  
call append(line(".")+2, "> Mail: kuling729@gmail.com")  
call append(line(".")+3, "> Created Time: ".strftime("%c"))  
call append(line(".")+4, " ********************************************/")  
call append(line(".")+5, "") 
endif 
if &filetype == 'cpp' 
call append(line(".")+6, "#include<iostream>") 
call append(line(".")+7, "using namespace std;") 
call append(line(".")+8, "") 
endif 
if &filetype == 'c' 
call append(line(".")+6, "#include<stdio.h>") 
call append(line(".")+7, "") 
endif 
"新建文件后,自动定位到文件末尾 
autocmd BufNewFile * normal G 
endfunc  
""""""""""""""""""""""""""""""""""""""""""" 
if has("syntax") 
syntax on 
endif 
set number 
set tabstop=4 
set softtabstop=4 
set shiftwidth=4 
set autoindent 
set cindent 
colorscheme evening 
let g:indent_guides_guide_size=1 
set tags=tags; 
set autochdir 
" If using a dark background within the editing area and syntax highlighting 
" turn on this option as well 
"set background=dark 
" Uncomment the following to have Vim jump to the last position when 
" reopening a file 
"if has("autocmd") 
"  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif 
"endif 
" Uncomment the following to have Vim load indentation rules and plugins 
" according to the detected filetype. 
"if has("autocmd") 
"  filetype plugin indent on 
"endif 
" The following are commented out as they cause vim to behave a lot 
" differently from regular Vi. They are highly recommended though. 
"set showcmd" Show (partial) command in status line. 
"set showmatch" Show matching brackets. 
"set ignorecase" Do case insensitive matching 
"set smartcase" Do smart case matching 
"set incsearch" Incremental search 
"set autowrite" Automatically save before commands like :next and :make 
"set hidden " Hide buffers when they are abandoned 
"set mouse=a" Enable mouse usage (all modes) 
" Source a global configuration file if available 
if filereadable("/etc/vim/vimrc.local") 
source /etc/vim/vimrc.local 
endif 


这样之后使用的VIM效果如下图:

vim开发配置,函数颜色格式设置


在Ubuntu 15.04下安装Vim:http://www.linuxdiyf.com/linux/11782.html

美化vim的PopupMenu选项背景颜色:http://www.linuxdiyf.com/linux/9886.html

Vim代码颜色配置-PHP版:http://www.linuxdiyf.com/linux/4645.html

Vim中文支持及颜色配置:http://www.linuxdiyf.com/linux/3421.html

Vi/Vim/gVim颜色自定义:http://www.linuxdiyf.com/linux/3422.html