台湾菜

Ubuntu配置记录-编程环境配置

twcai • ubuntu notes

GVIM在今天早上算是做好了最基本的配置,可以拿来写代码做算法题了。上次说到不知道配色文件在哪里配置=,=, 其实这是个小白问题,就在 /usr/share/vim/vim71/colors下面(vim71需要对你安装的gvim版本)。
Netbeans的中文显示问题,也算解决了,具体见下帖 : 安装日文支持以后NetBeans界面的字符乱码。当然,实际上跟日文支持是没有关系的。Netbeans的中文显示问题有很多解决方案,而且并非全部都很有效,所以碰到的话,还是需要都尝试一下。
尽管搞定了中文显示问题,但是netbeans下面的字体显示仍然非常难看,google了下ubuntu中文社区,据说可以通过修改配置文件完成。目前对linux的文件配置机制还不是很熟悉,而且主要还是用gvim来编码,因此把这个问题先暂且搁下。留下一个链接,方便以后解决:[问题][Netbeans] JRE[英文]字体配置问题
继续转强帖:
makefile编写
两篇很牛的vim使用技巧(1)
两篇很牛的vim使用技巧(2)

最后分享一下我的gvim配置文件和配色文件代码。
Update at 2010.Apr.13: 这两个文件因为会经常修改,我自己使用的最新版本将会放在DropBox上,随时供需要的人下载。也请路过的大牛多多指教。Download via .vimrc ctw.vim

ps. 如果下载后的配置文件中有^M字符,可以在gvim的命令模式下用下面这个命令来清除
:%s/[Ctrl-v][Enter]//g

" $HOME/.vimrc
" Collected and modified by CTW

" Basics {
" 关闭兼容模式
set nocompatible

" 设定文件浏览器目录为当前目录
set bsdir=buffer
set autochdir

" 设置编码
set enc=utf-8

" 设置文件编码检测类型及支持格式
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936

" 指定菜单语言
set langmenu=zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim

" 与windows共享剪切板
set clipboard+=unnamed

" 键盘操作
map gk
map gj

" 开放光标移动
set whichwrap=b,s,<,>,[,]

" 命令行高度
set cmdheight=1

" 中文帮助
if version > 603
set helplang=cn
endif

" 增强检索功能
set tags=./tags,./../tags,./**/tags

" 保存文件格式
set fileformats=unix
" }

" Visual {
" 设置配色文件
colo ctw

" 设置开启语法高亮
syntax on

" 设置初始窗体行数列数
set lines=36
set columns=124

" font
set guifont=Monaco

" 查找结果高亮度显示
set hlsearch

" tab宽度
set tabstop=4
set cindent shiftwidth=4
set autoindent shiftwidth=4
" }

" Autocommands {
" Enable load plugin files
filetype plugin on

" 自动补全
filetype plugin indent on

" 只在下列文件类型被侦测到的时候显示行号,普通文本文件不显示
if has("autocmd")
autocmd FileType xml,html,c,cs,java,perl,shell,sh,bash,cpp,python,vim,php,ruby set number
autocmd FileType xml,html vmap 'o'>o-->
autocmd FileType java,c,cpp,cs vmap ''>o*/
autocmd FileType html,text,php,vim,c,java,xml,bash,shell,perl,python setlocal textwidth=100
autocmd Filetype html,xml,xsl source $VIMRUNTIME/plugin/closetag.vim
" Error happend, repair needed
" autocmd BufReadPost *
" \ if line("'\"") > 0 && line("'\"") < = line("$") |
" \ exe "normal g`\"" |
" \ endif
endif " has("autocmd")

" 自动完成
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascrīpt set omnifunc=javascrīptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType java set omnifunc=javacomplete#Complete
" auto complete
" inoremap } }: O
" }

" C/C++ Programming {
" C/C++注释
set comments=://

" Enable OmniCppComplete
set nocp
set completeopt=menu

" Config OmniCppComplete
" autocomplete with .
let OmniCpp_MayCompleteDot = 1
" autocomplete with ->
let OmniCpp_MayCompleteArrow = 1
" autocomplete with ::
let OmniCpp_MayCompleteScope = 1
" select first item (but don't insert)
let OmniCpp_SelectFirstItem = 2
" search namespaces in this and included files
let OmniCpp_NamespaceSearch = 2
" show function prototype (i.e. parameters) in popup window
let OmniCpp_ShowPrototypeInAbbr = 1

" Add STL tags
set tags+=~/.myTags/stl.tags

" 修正自动C式样注释功能 <2005/07/16>
set comments=s1:/*,mb:*,ex0:/

" 临时:使用pthread的C源代码的编译
map :call PTHCompileRunGPP()
func! PTHCompileRunGPP()
exec "w"
exec "!gcc -D_REENTRANT % -o %< -g -lpthread"
endfunc

" C的编译和运行
map :call CCompileRunGpp()
func! CCompileRunGpp()
exec "w"
exec "!gcc % -o %< -ansi -g -Wall "
endfunc

" C++的编译和运行
map :call CPPCompileRunGpp()
func! CPPCompileRunGpp()
exec "w"
exec "!g++ % -o %< -ansi -g -Wall "
endfunc

" CTags
set completeopt=longest,menu

" TagList
" 按照名称排序
let Tlist_Sort_type = "name"

" 如果只有一个Buffer,kill窗口时也kill掉buffer
let Tlist_Exit_OnlyWindow = 1

" 只显示一个文件的Tag
let Tlist_Show_One_File=1

" Tlist Auto Open
let Tlist_Auto_Open=1

" }

配色文件:
" local syntax file - set colors on a per-machine basis:
" vim: tw=0 ts=4 sw=4
" Vim color file
" Based on "Murphy.vim"
" Maintainer: Ron Aaron
" Last Change: 2004 May 02
" Modified by CTW
" Last Modified : 20010 Apr 13

hi clear
set background=dark
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "ctw"

hi Constant term=underline ctermfg=LightGreen guifg=White gui=NONE
hi Ignore ctermfg=black guifg=bg
hi PreProc term=underline ctermfg=LightBlue guifg=Wheat
hi Search term=reverse guifg=white guibg=Blue
hi Special term=bold ctermfg=LightRed guifg=green
hi Error term=reverse ctermbg=Red ctermfg=White guibg=Red guifg=White
hi Todo term=standout ctermbg=Yellow ctermfg=Black guifg=Blue guibg=Yellow
" From the source:
hi Cursor guifg=Orchid guibg=fg
hi Directory term=bold ctermfg=LightCyan guifg=Cyan
hi ErrorMsg term=standout ctermbg=DarkRed ctermfg=White guibg=Red guifg=White
hi IncSearch term=reverse cterm=reverse gui=reverse
hi ModeMsg term=bold cterm=bold gui=bold
hi MoreMsg term=bold ctermfg=LightGreen gui=bold guifg=SeaGreen
hi NonText term=bold ctermfg=Blue gui=bold guifg=Blue
hi Question term=standout ctermfg=LightGreen gui=bold guifg=Cyan
hi SpecialKey term=bold ctermfg=LightBlue guifg=Cyan
hi StatusLine term=reverse,bold cterm=reverse gui=NONE guifg=White guibg=darkblue
hi StatusLineNC term=reverse cterm=reverse gui=NONE guifg=white guibg=#333333
hi Title term=bold ctermfg=LightMagenta gui=bold guifg=Pink
hi WarningMsg term=standout ctermfg=LightRed guifg=Red
hi Visual term=reverse cterm=reverse gui=NONE guifg=white guibg=darkgreen

" What I modified
hi Character guifg=magenta
hi cComment term=bold ctermfg=LightRed guifg=lightblue
hi Include guifg=orange
hi LineNr term=underline ctermfg=Yellow guifg=white
hi Macro guifg=orange
hi Normal ctermbg=Black ctermfg=lightgreen guibg=Black guifg=#FFFF7F
hi Number guifg=magenta gui=bold
hi PreCondit guifg=orange
hi Statement term=bold ctermfg=Yellow guifg=turquoise gui=NONE
hi cString guifg=magenta
hi Structure guifg=turquoise

" Nothing happened
hi Identifier term=underline ctermfg=LightCyan guifg=white
hi Operator guifg=white gui=NONE
hi Type ctermfg=LightGreen guifg=turquoise gui=none

comments powered by Disqus