您的位置:首页 > 其它

gvim emacs 保持一致

2011-10-10 09:58 197 查看

1 shiftwidth

这个是用于程序中自动缩进所使用的空白长度指示的。一般来说为了保持程序的美观,和下面的参数最好一致。同时它也是符号移位长度的制定者。

2 tabstop

定义tab所等同的空格长度,一般来说最好设置成8,因为如果是其它值的话,可能引起文件在打印之类的场合中看起来很别扭。除非你设置了
expandtab
模式,也就是把tabs转换成空格,这样的话就不会一起混淆,不过毕竟制表符为8是最常用最普遍的设置,所以一般还是不要改。

3 softtabstop

如果我们希望改变程序中的缩进怎么办?
shiftwidth
tabstop
不一样的话,你会发现程序比较难看的。这时候,
softtabstop
就起作用了。可以从vim的说明中看到,一旦设置了
softtabstop
的值时,你按下tab键,插入的是空格和tab制表符的混合,具体如何混合取决于你设定的
softtabstop
,举个例子,如果设定softtabstop=8,
那么按下tab键,插入的就是正常的一个制表符;如果设定 softtabstop=16,那么插入的就是两个制表符;如果softtabstop=12,那么插入的就是一个制表符加上4个空格;如果
softtabstop
=4呢?那么一开始,插入的就是4个空格,此时一旦你再按下一次tab,这次的四个空格就会和上次的四个空格组合起来变成一个制表符。换句话说,
softtabstop
是“逢8空格进1制表符”,前提是你
tabstop=8


4 关于expandtab

举个例子,在多人一起开发项目时,为了使代码风格尽量保持一致,一般不允许在代码使用TAB符,而以4个空格代之。我们可以编辑一个文件,包含下面的内容:

set shiftwidth=4

set expandtab

然后把下面的命令加入到.vimrc中:

autocmd FileType c,cpp set shiftwidth=4 | set expandtab


就可以只在编辑c和cpp文件时实行这种设置了

====================================================================================

我们知道emacs中缩进default是3个空格,tab的长度是8个空格。由此设定gvim中也采用此设置。 为了风格的统一我们在gvim中不使用tab,但是同样为了照顾makefile书写时要用到tab。 gvimrc如下

" An example for a gvimrc file.
" The commands in this are executed when the GUI is started.
"
" Maintainer:	Bram Moolenaar <Bram@vim.org>
" Last change:	2001 Sep 02
"
" To use it, copy it to
"     for Unix and OS/2:  ~/.gvimrc
"	      for Amiga:  s:.gvimrc
"  for MS-DOS and Win32:  $VIM\_gvimrc
"	    for OpenVMS:  sys$login:.gvimrc

" Make external commands work through a pipe instead of a pseudo-tty
"set noguipty

" set the X11 font to use
" set guifont=-misc-fixed-medium-r-normal--14-130-75-75-c-70-iso8859-1
"set guifont=courier-h14-w5-b-cRUSSIAN
"set guifont=-*-courier-medium-r-*-*-10-*-*-*-*-*-*-*
set ch=1		   " Make command line two lines high
set sw=3		   " set shift width of autoindent
set softtabstop=3  "just 3. not 4x
set tabstop=8      " use 4 blank instead tab
set cin            " c indent
set et			   " use space expand tab  //zhb
set expandtab      " do not want to see tab
set nobk           " not back up ~###
autocmd FileType Makefile set noexpandtab  "except makefile"
set sm             " confirm and jumping the match brace
set mousehide		" Hide the mouse when typing text
set textwidth=0     " no wrap
set linebreak       " line break with word

" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>

" Only do this for Vim version 5.0 and later.
if version >= 500

" I like highlighting strings inside C comments
let c_comment_strings=1

" Switch on syntax highlighting if it wasn't on yet.
if !exists("syntax_on")
syntax on
endif

" Switch on search pattern highlighting.
set hlsearch

" For Win32 version, have "K" lookup the keyword in a help file
"if has("win32")
"  let winhelpfile='windows.hlp'
"  map K :execute "!start winhlp32 -k <cword> " . winhelpfile <CR>
"endif

" Set nice colors
" background for normal text is light grey
" Text below the last line is darker grey
" Cursor is green, Cyan when ":lmap" mappings are active
" Constants are not underlined but have a slightly lighter background
"highlight Normal guibg=grey90
"highlight Cursor guibg=Green guifg=NONE
"highlight lCursor guibg=Cyan guifg=NONE
"highlight NonText guibg=grey80
"highlight Constant gui=NONE guibg=grey95
"highlight Special gui=NONE guibg=grey95
colors {murphy}

endif

"""""""""""""""""""""""""""""""""""""""""""""""""
""Added By Michael Kang to support tags
"""""""""""""""""""""""""""""""""""""""""""""""""
" Map TagList open key
nnoremap <silent> <F8> :TlistToggle<CR>
nnoremap <silent> <F11> :TlistAddFilesRecursive . *.sv<CR>
nnoremap <silent> <F12> :TlistAddFiles *.h *.cpp<CR>

" Add SystemVerilog tags and configure Tag window
set tags+=./tags,/home/ckang/.vim/sctag/cpp_tags,/home/ckang/.vim/sctag/sc_tags

" Add SystemVerilog tags and configure Tag window
set tags+=./tags,/home/ckang/.vim/svtag/tags
"set tags+=./tags,/home/ckang/.vim/svtag/tags,/home/ckang/.vim/svtag/tags_wz_brace
"set tags+=/home/ckang/.vim/svtag/vera_tags

"let Tlist_Show_One_File = 1
let Tlist_Exit_OnlyWindow = 1
let Tlist_Show_Menu =1
let Tlist_Process_File_Always = 1

" Expand SystemVerilog and registered to taglist window

let tlist_systemverilog_settings='systemverilog;m:module;p:program;i:interface;c:class;t:task;f:function;e:typedef;d:define'

"Vera ctags extract
"let tlist_systemverilog_settings= 'systemverilog;c:class;d:macro;e:enumerator;f:function;g:enum;m:member;p:program;P:prototype;t:task;T:typedef;v:variable;x:externvar'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐