Debian下VIM的安装和配置

1.安装

apt-get install vim

2.配置

这是我的vim 配饰文件,基本的功能都能实现,在这里做一个备份,省的以后重装系统还要到处找这个配置文件(/etc/vim/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

" following enables syntax highlighting by default.

if has("syntax")

syntax on

endif

" 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)

"*******************************************************

"Personal configuration

"*******************************************************

set fileencodings=utf-8,gbk,ucs-bom,cp936

set encoding=utf-8

set nocompatible

set number

filetype on

filetype indent on

filetype plugin on

set history=1000

set background=dark

syntax on

"set autoindent

"set smartindent

set showmatch

set guioptions-=T

set vb t_vb=

set ruler

set nohls

:set cindent

set tabstop=4

set shiftwidth=8

set incsearch

set cursorline

set nobackup

set mouse=a

set hlsearch "set high light search, cancel the high light is set nohlsearch

:set  laststatus=2

:set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" CSCOPE settings for vim

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"

" This file contains some boilerplate settings for vim‘s cscope interface,

" plus some keyboard mappings that I‘ve found useful.

"

" USAGE:

" -- vim 6:     Stick this file in your ~/.vim/plugin directory (or in a

"               ‘plugin‘ directory in some other directory that is in your

"               ‘runtimepath‘.

"

" -- vim 5:     Stick this file somewhere and ‘source cscope.vim‘ it from

"               your ~/.vimrc file (or cut and paste it into your .vimrc).

"

" NOTE:

" These key maps use multiple keystrokes (2 or 3 keys).  If you find that vim

" keeps timing you out before you can complete them, try changing your timeout

" settings, as explained below.

"

" Happy cscoping,

"

" Jason Duell       [email protected]     2002/3/7

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" This tests to see if vim was configured with the ‘--enable-cscope‘ option

" when it was compiled.  If it wasn‘t, time to recompile vim...

if has("cscope")

""""""""""""" Standard cscope/vim boilerplate

" use both cscope and ctag for ‘ctrl-]‘, ‘:ta‘, and ‘vim -t‘

set cscopetag

" check cscope for definition of a symbol before checking ctags: set to 1

" if you want the reverse search order.

set csto=0

" add any cscope database in current directory

if filereadable("cscope.out")

cs add cscope.out

" else add the database pointed to by environment variable

elseif $CSCOPE_DB != ""

cs add $CSCOPE_DB

endif

" show msg when any other cscope db added

set cscopeverbose

""""""""""""" My cscope/vim key mappings

"

" The following maps all invoke one of the following cscope search types:

"

"   ‘s‘   symbol: find all references to the token under cursor

"   ‘g‘   global: find global definition(s) of the token under cursor

"   ‘c‘   calls:  find all calls to the function name under cursor

"   ‘t‘   text:   find all instances of the text under cursor

"   ‘e‘   egrep:  egrep search for the word under cursor

"   ‘f‘   file:   open the filename under cursor

"   ‘i‘   includes: find files that include the filename under cursor

"   ‘d‘   called: find functions that function under cursor calls

"

" Below are three sets of the maps: one set that just jumps to your

" search result, one that splits the existing vim window horizontally and

" diplays your search result in the new window, and one that does the same

" thing, but does a vertical split instead (vim 6 only).

"

" I‘ve used CTRL-\ and [email protected] as the starting keys for these maps, as it‘s

" unlikely that you need their default mappings (CTRL-\‘s default use is

" as part of CTRL-\ CTRL-N typemap, which basically just does the same

" thing as hitting ‘escape‘: [email protected] doesn‘t seem to have any default use).

" If you don‘t like using ‘[email protected]‘ or CTRL-\, , you can change some or all

" of these maps to use other keys.  One likely candidate is ‘CTRL-_‘

" (which also maps to CTRL-/, which is easier to type).  By default it is

" used to switch between Hebrew and English keyboard mode.

"

" All of the maps involving the <cfile> macro use ‘^<cfile>$‘: this is so

" that searches over ‘#include <time.h>" return only references to

" ‘time.h‘, and not ‘sys/time.h‘, etc. (by default cscope will return all

" files that contain ‘time.h‘ as part of their name).

" To do the first type of search, hit ‘CTRL-\‘, followed by one of the

" cscope search types above (s,g,c,t,e,f,i,d).  The result of your cscope

" search will be displayed in the current window.  You can use CTRL-T to

" go back to where you were before the search.

"

nmap <C-\>s :cs find s <C-R>=expand("<cword>")<CR><CR>

nmap <C-\>g :cs find g <C-R>=expand("<cword>")<CR><CR>

nmap <C-\>c :cs find c <C-R>=expand("<cword>")<CR><CR>

nmap <C-\>t :cs find t <C-R>=expand("<cword>")<CR><CR>

nmap <C-\>e :cs find e <C-R>=expand("<cword>")<CR><CR>

nmap <C-\>f :cs find f <C-R>=expand("<cfile>")<CR><CR>

nmap <C-\>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>

nmap <C-\>d :cs find d <C-R>=expand("<cword>")<CR><CR>

" Using ‘CTRL-spacebar‘ (intepreted as [email protected] by vim) then a search type

" makes the vim window split horizontally, with search result displayed in

" the new window.

"

" (Note: earlier versions of vim may not have the :scs command, but it

" can be simulated roughly via:

"    nmap <[email protected]>s <C-W><C-S> :cs find s <C-R>=expand("<cword>")<CR><CR>

nmap <[email protected]>s :scs find s <C-R>=expand("<cword>")<CR><CR>

nmap <[email protected]>g :scs find g <C-R>=expand("<cword>")<CR><CR>

nmap <[email protected]>c :scs find c <C-R>=expand("<cword>")<CR><CR>

nmap <[email protected]>t :scs find t <C-R>=expand("<cword>")<CR><CR>

nmap <[email protected]>e :scs find e <C-R>=expand("<cword>")<CR><CR>

nmap <[email protected]>f :scs find f <C-R>=expand("<cfile>")<CR><CR>

nmap <[email protected]>i :scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>

nmap <[email protected]>d :scs find d <C-R>=expand("<cword>")<CR><CR>

" Hitting CTRL-space *twice* before the search type does a vertical

" split instead of a horizontal one (vim 6 and up only)

"

" (Note: you may wish to put a ‘set splitright‘ in your .vimrc

" if you prefer the new window on the right instead of the left

nmap <[email protected]><[email protected]>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>

nmap <[email protected]><[email protected]>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>

nmap <[email protected]><[email protected]>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>

nmap <[email protected]><[email protected]>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>

nmap <[email protected]><[email protected]>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>

nmap <[email protected]><[email protected]>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>

nmap <[email protected]><[email protected]>i :vert scs find i ^<C-R>=expand("<cfile>")<CR>$<CR>

nmap <[email protected]><[email protected]>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>

""""""""""""" key map timeouts

"

" By default Vim will only wait 1 second for each keystroke in a mapping.

" You may find that too short with the above typemaps.  If so, you should

" either turn off mapping timeouts via ‘notimeout‘.

"

"set notimeout

"

" Or, you can keep timeouts, by uncommenting the timeoutlen line below,

" with your own personal favorite value (in milliseconds):

"

"set timeoutlen=4000

"

" Either way, since mapping timeout settings by default also set the

" timeouts for multicharacter ‘keys codes‘ (like <F1>), you should also

" set ttimeout and ttimeoutlen: otherwise, you will experience strange

" delays as vim waits for a keystroke after you hit ESC (it will be

" waiting to see if the ESC is actually part of a key code like <F1>).

"

"set ttimeout

"

" personally, I find a tenth of a second to work well for key code

" timeouts. If you experience problems and have a slow terminal or network

" connection, set it higher.  If you don‘t set ttimeoutlen, the value for

" timeoutlent (default: 1000 = 1 second, which is sluggish) is used.

"

"set ttimeoutlen=100

endif

" Title:        Verilog HDL/SystemVerilog HDVL indent file

" Maintainer: Mingzhi Li <[email protected]>

" Last Change: 2007-12-16 20:10:57 CST

"

" Buffer Variables:

"     b:verilog_indent_width   : indenting width(default value: shiftwidth)

"

" Install:

"     Drop it to ~/.vim/indent

"

" URL:

"    http://www.vim.org/scripts/script.php?script_id=2091

"

" Revision Comments:

"     Mingzhi Li  2007-12-16 20:09:39 CST Version 1.2

"        Bug fixes

"     Mingzhi Li  2007-12-13 23:47:54 CST Version 1.1

"        Bug fix, improve performance and add introductions

"     Mingzhi Li  2007-12-7  22:16:41 CST Version 1.0

"        Initial version

"

" Known Limited:

"     This indent file can not work well, when you break the long line into

"     multi-line manually, such as:

"      always @(posedge a or posedge b

"          or posedge c ) begin

"         //...

"      end

"     Recommend to use the coding style(wraped by vim automatically) as following:

"       always @(posedge a or posedge b or posedge c ) begin

"         //...

"       end

" Only load this indent file when no other was loaded.

if exists("b:did_indent")

finish

endif

let b:did_indent = 1

setlocal indentexpr=GetVerilog_SystemVerilogIndent()

setlocal indentkeys=!^F,o,O,0),0},0{,=begin,=end,=fork,=join,=endcase,=join_any,=join_none

setlocal indentkeys+==endmodule,=endfunction,=endtask,=endspecify

setlocal indentkeys+==endclass,=endpackage,=endsequence,=endclocking

setlocal indentkeys+==endinterface,=endgroup,=endprogram,=endproperty

setlocal indentkeys+==`else,=`endif

" Only define the function once.

if exists("*GetVerilog_SystemVerilogIndent")

finish

endif

set cpo-=C

function s:comment_ind(lnum)

let line = getline(a:lnum)

if line =~ ‘^\s*\/\/‘

return -1

endif

let firstPos = match(line,‘\S‘) + 1

if firstPos == 0

return -1

endif

let endPos   = match(line,‘\s*$‘)

let flag1 = 0

let flag2 = 0

if (synIDattr(synID(a:lnum, firstPos, 1), "name") =~? ‘\(Comment\|String\)$‘)

let flag1 = 1

endif

if (synIDattr(synID(a:lnum, endPos, 1), "name") =~? ‘\(Comment\|String\)$‘ )

let flag2 = 1

endif

if ((1 == flag1)&&(1 == flag2))

let firstPos = match(line,‘\*\/‘) + 2

if (synIDattr(synID(a:lnum, firstPos, 1), "name") =~? ‘\(Comment\|String\)$‘)

return -1

else

return 3

endif

endif

if (1 == flag1)

return 1

endif

if (1 == flag2)

return 0

endif

return 2

endfunction

function s:prevnonblanknoncomment(lnum)

let lnum = prevnonblank(a:lnum)

while lnum > 0

if (-1 != s:comment_ind(lnum))

break

endif

let lnum = prevnonblank(lnum - 1)

endwhile

return lnum

endfunction

function s:removecommment(line,comment_ind)

if (a:comment_ind ==  2)

return a:line

endif

if (a:comment_ind == -1)

return ""

endif

if (a:comment_ind == 1)

return substitute(a:line,‘^.\{-}\*\/‘,"","")

endif

let myline01 = a:line;

if (a:comment_ind == 3)

let myline01 = substitute(myline01,‘^.\{-}\*\/‘,"","")

endif

let myline01 = substitute(myline01,‘\/\*.*$‘,"","")

return substitute(myline01,‘\/\/.*$‘,"","")

endfunction

function GetVerilog_SystemVerilogIndent()

if exists(‘b:verilog_indent_width‘)

let offset = b:verilog_indent_width

else

let offset = &sw

endif

" Find a non-blank and valid line above the current line.

let lnum = s:prevnonblanknoncomment(v:lnum - 1)

" At the start of the file use zero indent.

if lnum == 0

return 0

endif

let ind  = indent(lnum)

let curr_line_ind = s:comment_ind(v:lnum)

"if curr_line_ind == -1

"  return ind

"endif

let curr_line  = s:removecommment(getline(v:lnum),curr_line_ind)

let curr_line2 = substitute(curr_line,‘^\s*‘,‘‘,‘‘)

let match_result = matchstr(curr_line2,‘^\<\(end\|else\|end\(case\|task\|function\|clocking\|interface\|module\|class\|specify\|package\|sequence\|group\|property\)\|join\|join_any\|join_none\)\>\|^}\|`endif\|`else‘)

if len(match_result) > 0

if match_result =~ ‘\<end\>‘

let match_start = ‘\<begin\>‘

let match_mid   = ‘‘

let match_end   = ‘\<end\>‘

elseif match_result =~ ‘\<else\>‘

let last_line_ind = s:comment_ind(lnum)

let last_line  = s:removecommment(getline(lnum),last_line_ind)

if last_line =~ ‘^\s*end\|^\s*}‘

return indent(lnum)

else

let match_start = ‘\<if\>‘

let match_mid   = ‘‘

let match_end   = ‘\<else\>‘

endif

elseif match_result =~ ‘join‘

let match_start = ‘\<fork\>‘

let match_mid   = ‘‘

let match_end   = ‘\<\(join\|join_none\|join_any\)\>‘

elseif match_result =~ ‘}‘

let match_start = ‘{‘

let match_mid   = ‘‘

let match_end   = ‘}‘

elseif match_result =~ ‘`else‘

let match_start = ‘`if‘

let match_mid   = ‘‘

let match_end   = ‘`else‘

elseif match_result =~ ‘`endif‘

let match_start = ‘`if‘

let match_mid   = ‘`else‘

let match_end   = ‘`endif‘

else

let match_start = substitute(match_result,‘^end‘,‘‘,‘‘)

let match_start = ‘\<‘ . match_start . ‘\>‘

let match_mid   = ‘‘

let match_end   = ‘\<‘ . match_result. ‘\>‘

endif

call cursor(v:lnum,1)

let match_line = searchpair(match_start,match_mid,match_end,‘bW‘,

\" synIDattr(synID(line(‘.‘),col(‘.‘),1),‘name‘)"

\. "=~? ‘\\(Comment\\|String\\)$‘")

if match_line > 0

return indent(match_line)

endif

endif

let last_line_ind = s:comment_ind(lnum)

let last_line  = s:removecommment(getline(lnum),last_line_ind)

let indent0 = 0

let indent1 = 0

let indent2 = 0

let de_indent0 = 0

let pat0 = ‘[{(]\s*$‘

let pat1 = ‘\<\(begin\|fork\)\>\s*\(:\s*\w\+\s*\)\=\s*$‘

let pat2 = ‘`\@<!\<\(if\|else\)\>‘

let pat3 = ‘\<\(always\|initial\|for\|foreach\|always_comb\|always_ff\|always_latch\|final\|repeat\|while\|constraint\|do\)\>‘

let pat5 = ‘\<\(case\%[[zx]]\|task\|function\|class\|interface\|clocking\|randcase\|package\|specify\)\>‘

let pat6 = ‘^\s*\(\w\+\s*:\)\=\s*\<covergroup\>‘

let pat7 = ‘^\s*\<\(begin\|fork\)\>\s*\(:\s*\w\+\s*\)\=‘

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

if last_line =~ pat0 || last_line =~ pat1

let indent0 = 1

endif

" Indent after if/else/for/case/always/initial/specify/fork blocks

if (last_line =~ pat2 ||  last_line =~ pat3 || last_line =~ ‘:\s*$‘) && (last_line !~ ‘;\s*$‘)

let indent1 = 1

elseif  last_line =~ pat5 || last_line =~ pat6

let indent2 = 1

elseif last_line =~ ‘^\s*`\<\(ifdef\|else\|ifndef\)\>‘

return ind + offset

endif

let sum1 = indent0 + indent1 + indent2

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

if (curr_line =~ pat7 || curr_line =~ ‘^\s*{‘)

let de_indent0 = 1

endif

if (sum1 == 0) && (last_line !~ ‘^\s*end\|\<begin\>‘) &&

\ (curr_line =~ ‘)\s*;\s*$‘) &&

\ (last_line =~ ‘,\s*$‘ || last_line =~ ‘\w\s*$\|]\s*$\|)\s*$‘)

return ind - offset

endif

let sum2 = de_indent0

if indent0 + indent1 + sum2 == 0

let lnum2 = s:prevnonblanknoncomment(lnum - 1)

let last_line2_ind = s:comment_ind(lnum2)

let last_line2 = s:removecommment(getline(lnum2),last_line2_ind)

if ((last_line2 !~ pat0 && last_line2 !~ pat1) &&

\ (last_line2 =~ pat2 || last_line2 =~ pat3 || last_line2 =~ ‘:\s*$‘) &&

\ (last_line =~ ‘;\s*$‘))

return indent(lnum2)

endif

endif

" Return the indention

if (indent0 == 0 && indent1 == 1 && de_indent0 == 1)

return ind

elseif  sum1 > 0

return ind + offset

elseif  sum2 > 0

return ind - offset

else

return ind

endif

endfunction

" vim:sw=2

"***********************Verilg & SystemVerilog Configure Ends*******************

"********************************************************************************

"Mark Sets

"********************************************************************************

let mapleader = "."

"***********************Mark Sets End*******************************************

"********************************************************************************

"Personal configuration is End

"********************************************************************************

" Source a global configuration file if available

if filereadable("/etc/vim/vimrc.local")

source /etc/vim/vimrc.local

endif

时间: 2024-10-10 16:05:56

Debian下VIM的安装和配置的相关文章

ubuntu下vim的安装与配置

由于ubuntu16.04已经可以用vim直接打开文件,所以大可不必使用gvim了,vim显得更加轻巧. vim的安装: sudo apt-get install vim sudo apt-get install vim-gnome vim的配置: 1.在/home下,Ctrl + H显示隐藏文件, 新建文件.vimrc,便可对vim进行配置. set ai set aw set ar set si set sc set sm set cin set hls set go=0 set bs=2

windows下vim的安装与配置

gvim7.4 1.安装 2.配置 打开安装目录下的_vimrc文件 ①设置语法高亮 set nu! colorscheme desert syntax enable syntax on 显示行号,使用desert配色方案,打开语法高亮功能(用不同颜色显示注释.关键字.字符串等).

centos下vim的安装与配置

1 安装 (如果是新装的centos,最好按照vim之前,先Linux中必备常用支持库的安装:http://blog.csdn.net/clevercode/article/details/45438401) # yum -y install vim* 2 查看vim的位置 # whereis vim 3 如果普通用户vim不高亮 如果/home下面的用户vim不高亮: $ echo $TERM vt100 3.1 解决方案一 将终端修改成为xterm.如下,重新登录即可. 重新登录 $ exi

【Linux】LINUX操作系统下VIM的安装和配置

vim是从VI发展而来的一个文本编辑器,功能更强大.而vim.tiny是vim的精简版,所以,安装vim势在必行.同时Windows下程序员很多都很喜欢Source Insight这个工具来看代码,各种语法高亮看着很舒服.vim作为为程序员打造的编辑器,没有道理不可以通过配置让程序员舒服地编辑代码,但是新手通常很难将其配置成顺手顺眼的环境.下面的方法可以通过极其简单的方式把vim配置得跟Source Insight一样炫. 一.安装环境: LINUX操作系统(ubuntu/Centos) 二.v

Ubuntu 下 vim 搭建python 环境 配置

在Windows下用惯了各种现成的工具,转到Linux下,一下没了头绪--好歹google出一些别人的心得,折腾来折腾去,也算是把开发环境配好了. 1. 安装完整的vim # apt-get install vim-gnome 2. 安装ctags,ctags用于支持taglist,必需! # apt-get install ctags 3. 安装taglist #apt-get install vim-scripts #apt-get install vim-addon-manager //

linux下redis的安装及配置启动

linux下redis的安装及配置启动 标签: redisnosql 2014-10-24 14:04 19732人阅读 评论(0) 收藏 举报  分类: 数据与性能(41)  wget http://download.redis.io/releases/redis-2.8.6.tar.gztar xzf redis-2.8.6.tar.gzcd redis-2.8.6make 有是make会报错 gcc类的错误 则需安装 gcc 如: yum install -y gcc g++ gcc-c+

Ubuntu 14.04下PostgreSQL-9.3安装与配置

最近要在linux下使用PostgreSQL,在网上搜了下资料,整理下PostgreSQL-9.3安装与配置 第一步:安装PostgreSQL sudo apt-get install postgresql-9.3 第二步:配置PostgreSQL默认用户的密码 1 sudo su postgres -c psql postgresql; 2 ALTER USER postgres WITH PASSWORD ' 你的密码'; 3 \q 4 sudo passwd postgres 说明:1进入

windows下Emacs的安装与配置

windows下Emacs的安装与配置 1.下载到这个网址可以下载到Emacs的windows版本:http://ftp.gnu.org/pub/gnu/emacs/windows/只需要一个压缩文档,如emacs-23.2-bin-i386.zip 2.安装在D盘根目录下新建一个文件夹,取名Emacs23.2(也可以是其他路径,随个人喜好而定),将emacs-23.2-bin- i386.zip里的文件解压到这个目录下,这样在d:\Emacs23.2\下就有bin, tec, info, le

【原创】Centos下telnet的安装和配置(完全版,Centos5.5亲测)

Centos下telnet的安装和配置(完全版,Centos5.5亲测) 一.查看本机是否有安装telnet(centOS5默认有安装telnet) # rpm -qa |grep telnet 如果显示结果为: telnet-0.17-39.el5 telnet-server-0.17-39.el5 那恭喜你,机器上已经安装了telnet.如果没有安装,请看下一步. 特别说明: telnet分为telnet-client (简称为telnet)和telnet-server.telnet-cli