ubuntu下怎么高亮显示逻辑运算符号和算数运算符,高手指点迷津,谢!!,我把我的vim 贴出来希望对大家有用

Vim、Emacs配置和使用
回复
tanshuang
帖子: 21
注册时间: 2010-09-28 10:36

ubuntu下怎么高亮显示逻辑运算符号和算数运算符,高手指点迷津,谢!!,我把我的vim 贴出来希望对大家有用

#1

帖子 tanshuang » 2010-10-12 13:47

我想把vim 打造成自己的编程工具,插件基本上按吴根指导那样装上了,很好用.但我想想高亮逻辑运算符号,算术运算符号,按下面的代码放到~/.vim/syntax 不好用,好像只能再gvim 下使用,哪位高手指点一下迷津,按帮助文档学太慢了,尽管我在学,但还是很艰难,我怎么才能让逻辑运算符号和算术运算符号高亮显示 :em06


代码:
"========================================================
" Highlight All Function
"========================================================
syn match cFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>[^()]*)("me=e-2
syn match cFunction "\<[a-zA-Z_][a-zA-Z_0-9]*\>\s*("me=e-1
hi cFunction gui=NONE guifg=#B5A1FF

"========================================================
" Highlight All Math Operator
"========================================================
" C math operators
syn match cMathOperator display "[-+\*/%=]"
" C pointer operators
syn match cPointerOperator display "->\|\."
" C logical operators - boolean results
syn match cLogicalOperator display "[!<>]=\="
syn match cLogicalOperator display "=="
" C bit operators
syn match cBinaryOperator display "\(&\||\|\^\|<<\|>>\)=\="
syn match cBinaryOperator display "\~"
syn match cBinaryOperatorError display "\~="
" More C logical operators - highlight in preference to binary
syn match cLogicalOperator display "&&\|||"
syn match cLogicalOperatorError display "\(&&\|||\)="

" Math Operator
hi cMathOperator guifg=#3EFFE2
hi cPointerOperator guifg=#3EFFE2
hi cLogicalOperator guifg=#3EFFE2
hi cBinaryOperator guifg=#3EFFE2
hi cBinaryOperatorError guifg=#3EFFE2
hi cLogicalOperator guifg=#3EFFE2
hi cLogicalOperatorError guifg=#3EFFE2
目前
我主要是使用C编程:

代码: 全选

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

" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif
"关闭vi兼容
set nocp
"语法高亮
syntax enable
syntax on
filetype plugin indent on

"taglist
let Tlist_Ctags_Cmd='/usr/local/bin/ctags'
let Tlist_Show__One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Auto_Open=0
let Tlist_Auto_Update=1
"色彩
colorscheme delek
"ctags设置
set tags=tags,./tags
"自动缩进
set autoindent
set cindent
"minibuff
let g:miniBufExplMapWindowNavVim=1
let g:miniBufExplMapWindowNavArrows=1
let g:miniBufExplMapCtapSwitchBufs=1
let g:miniBufExplModSelTarget=1
"a.vim配置
nnoremap <silent><F12> :A<CR>
"grep
nnoremap <silent><F5> :Grep<CR>
"supertap
let g:SuperTabRetainCompletionType=2
let g:SuperTabDefaultCompletionType="<C-X><C-O>"
"智能补全
set completeopt=longest,menu
map <C-F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
"设置行号
set nu
"设置trinity
nmap <F8> :TrinityToggleAll<CR>
nmap <F9> :TrinityToggleSourceExplorer<CR>
nmap <F3> :TrinityToggleTagList<CR>
nmap <F4> :TrinityToggleNERDTree<CR>
"设置srcexpl
let g:SrcExpl_winHeight=8
let g:SrcExpl_refreshTime=100
let g:SrcExpl_jumpKey="<ENTER>"
let g:SrcExpl_gobackKey="<SPACE>"
let g:SrcExpl_pluginList=[
            \"__Tag_List__",
            \"_NERD_tree_",
            \"Source_Explorer"
            \]
let g:SrcExpl_searchLoalDef=1
let g:SrcExpl_isUpdateTags=0
let g:SrcExpl_updateTagsCmd="ctags --sort=foldcase -R."
let g:SrcExpl_updateTagsKey="<F12>"
"快捷键
:imap <F2> <Esc>:w<CR>
:nmap ` :q!<CR>
:imap { {<CR>}<Esc>kA<CR>
"设置显示中文字体
let &termencoding=&encoding
set fileencodings=utf-8,gbk,ucs-bom,cp936
上次由 tanshuang 在 2010-10-26 15:58,总共编辑 2 次。
tanshuang
帖子: 21
注册时间: 2010-09-28 10:36

Re: ubuntu下怎么高亮显示逻辑运算符号和算数运算符,高手指点迷津,谢!!

#2

帖子 tanshuang » 2010-10-26 15:52

没人帮我啊,哎,看来只能自己慢慢的摸索了
tanshuang
帖子: 21
注册时间: 2010-09-28 10:36

Re: ubuntu下怎么高亮显示逻辑运算符号和算数运算符,高手指点迷津,谢!!,我把我的vim 贴出来希望对大家有用

#3

帖子 tanshuang » 2010-10-26 17:07

我的问题已经解决了呵呵,强烈建议大家在ubuntu vim增加std_c.vim和cSyntaxAfter这个插件,官网上有下,很好用,可以加亮运算符
回复