本文取自: http://www.linuxsir.org/bbs/thread329987.html, 看了不是很了解, 請先進說明, 謝謝!
Reiser4 安裝方法
安裝理由:
看上reiser4的壓縮比與性能,並且我想重做個乾淨的系統(當前系統安裝的軟件太多了,有4G)。
風險:
reiser4一直沒合入正式內核,並且現在主要開發者已經入獄,應用前先要考慮。
問題:
安裝使用的2.6.25.4內核,好像不支持845pe的聲卡。所以在試用前最好先用新內核檢查設備驅動是不是正常,特別是聲卡。
本文研究通過cdebootstrap進行全新系統安裝的方法。
前提是需要已有一個Linux系統,及一個150M的空白分區(高級一點做法是通過initrd進行)。
安裝方法是先通過cdebootstrap安裝一個最小系統到空白分區,再從空白分區安裝最系統到原始分區。
安裝過程的注意點:
1. grub無法引導reiser4文件系統,只能使用lilo,不過lilo的寫入速度很慢,不知可有方法可解決此問題。
2. 使用udev的時候,/dev目錄也必須有console文件與null文件,不然無法啟動。
3. cdebootstrap安裝的最小系統好像比debootstrap要小,只有56M,不會有多餘軟件。但是cdebootstrap不會安裝base-config,後面需要自己對系統的各部分進行手工配置。
安裝後大小600M左右,使用E17做窗口管理器,源是 deb http://debian.alphagemini.org/ unstable main
安裝後reiser4的使用感受:個人感覺性能比reiser3.6要高,也許只是心理作用。
不過用reiser4是需要膽量的,現在namesys的網站都上不去了,它也沒有加到正式的內核中,後面的維護無法保證。
另外在/home分區中使用了reiser4的gzip壓縮選項,但感覺好像沒有效果,不知是不是已經取消此功能。
1. 編譯一個支持reiser4的內核:
從www.kernel.org上下載2.6.25.4內核
從http://www.kernel.org/pub/linux/kern...iser4-for-2.6/ 下載reiser4補丁
然後在kernel目錄下應用下面命令打補丁
patch -p1 ../reiser4-for-2.6.25.patch
編譯並選擇reiser4支持,重啟
2. 安裝cdebootstrap,並在一個新的空白分區上應用cdebootstrap生成一個新文件系統:
我是使用的swap分區(/dev/hda10)。只要有大於150M的分區就可以繼續。
先做如下工作:
swapoff # 停止swap分區,
vi/etc/fstab 讓系統啟動時不自動mount swap分區
fdisk 修改swap分區的分區類型為83
apt-get install reiser4progs # 安裝reiser4工具以用它創建分區,
apt-get install cdebootstrap # 安裝cdebootstrap工具,以利用它安裝新系統
如果不準備重裝系統,那需要安裝lilo。要是準備完全重裝則不需要:
apt-get install lilo
mkfs.reiser4 /dev/hda10 # 把swap分區變成reiser4分區以安裝最小系統
mount /mnt/tmp /dev/hda10 # 把hda10 mount到/mnt/tmp
然後開始安裝最小系統,使用下面命令安裝:
cdebootstrap -f minimal sid /mnt/tmp http://debian.cn99.com/debian
minimal 表示最小安裝,
sid 表示安裝的是sid版本,
http://debian.cn99.com/debian 表示使用這個源進行安裝
安裝時間很快,一般幾分鐘就可以搞好。安裝過程使用的空間大小為122M,安裝後的空間為64M。
4. 配置最小系統。先把當前的系統配置複製到最小系統上。
配置包括下面內容:文件系統mount信息、網絡信息、設備文件、內核啟動文件。
cp -a /dev/* /mnt/tmp/dev # 設備文件
cp -a /lib/modules /mnt/tmp/lib # 內核模塊
cp -a /boot/vmlinuz* /mnt/tmp/boot # 內核
cp -a /boot/System.map* /mnt/tmp/boot # 內核map
cp -a /boot/config* /mnt/tmp/boot # 內核配置
cp /etc/fstab /mnt/tmp/etc # 文件系統mount信息
mkdir /mnt/tmp/etc/network
cp /etc/network/interfaces /mnt/tmp/etc/network # 網絡配置
cp /etc/hostname /mnt/tmp/etc/ # 本機主機名配置
cp /etc/hosts /mnt/tmp/etc/ # 主機名配置
然後修改/mnt/tmp/etc/fstab, 把 / 對應的分區修改成hda10
5. 使用chroot切換到/mnt/tmp目錄下,安裝其它軟件讓這個分區可以自己啟動。
先mount proc再chroot:
mount -t proc proc /mnt/tmp/proc
chroot /mnt/tmp
6. 配置/dev/hda10環境,
passwd # 設置root口令。
apt-get install lilo # 必須使用lilo. grub不支持從reiser4啟動。
liloconf # 配置lilo, 設置讓它安裝在/dev/hda10, 並且不安裝到mbr不修改活動分區
lilo # 寫lilo啟動信息到/dev/hda10
如果需要對舊/分區(/dev/hda2)進行全新重裝,再繼續下面命令:
apt-get install reiser4progs #
apt-get install cdebootstrap # 用於在/dev/hda2上重裝最小系統
apt-get install pppoe pppoeconf sysklogd # 我是使用pppoe安裝的,需要安裝pppoe
pppoeconf # 配置ppp信息
修改grub, 本人使用grub4dos引導linux,需要在c:\menu.1st文件中增加下面配置:
title Mini System
rootnoverify (hd0,9)
chainloader +1
6. 重起進入 /dev/hda10。
7. 如果不需要對/dev/hda2進行重裝,則
只需要把/dev/hda2分區中內容複製到其它分區,
然後把/dev/hda2創建成reiser4,再把文件複製回就可以。
mount /dev/hda2 /mnt/old
mount /dev/hda5 /mnt/back # 備份分區,分區不可以是vfat之類的,如果是vfat應該使用tar 進行備份
cp -a /mnt/old /mnt/back # 備份
umount /mnt/old
mkfs.reiser4 /dev/hda2
mount /dev/hda2 /mnt/old
cp -a /mnt/back /mnt/old # 恢復原來的備份
恢復好後,設置使用lilo啟動/dev/hda2
mount -t proc proc /mnt/old/proc
chroot /mnt/old
liloconf # 配置lilo, 設置讓它安裝在/dev/hda2, 並且不安裝到mbr不修改活動分區
lilo # 寫lilo啟動信息到/dev/hda2
修改grub, 本人使用grub4dos引導linux,需要在c:\menu.1st文件中增加下面配置:
title Debian
rootnoverify (hd0,1)
chainloader +1
再重啟就OK。
重啟後, /dev/hda10里面的內容就沒用了,但可以使用這個文件系統做成一個initrd,以便後面進行系統維護。
先刪除此文件系統中無用的文件,一般為 locale、info、man、doc,另外還有vim中自帶的文檔與無用的插件,還有/var目錄下一些apt使用的信息。
清好後
使用這個命令生成initrd文件:
find . | cpio -H newc -o | gzip -9 > /tmp/initrd.img
本人清理後的文件系統是55M,做成的initrd是21M
8. 如果需要完全重裝,先檢查pppoe是否可用。
pon dsl-provider # 撥號
ifconfig # 多試幾下,如果還不出現ppp設備那表示不可用,使用plog 查看出錯信息
如果ppp不可用,繼續解決ppp問題直到可用。
一般ppp不可用的原因之一是eth0沒有啟動,可以使用
ifconfig eth0 192.168.0.1 255.0.0.0 up 啟動網卡
再重複上面的流程。
9. pppoe可用後,使用cdebootstrap安裝新系統:
先備份原來的/etc目錄和/root /home目錄,再格/dev/hda2
mkfs.reiser4 /dev/hda2
mount /dev/hda2 /mnt/tmp
cdebootstrap -f minimal sid /mnt/tmp http://debian.cn99.com/debian
把系統文件複製到新系統:
cp -a /dev/* /mnt/tmp/dev # 設備文件
cp -a /lib/modules /mnt/tmp/lib # 內核模塊
cp -a /boot/vmlinuz* /mnt/tmp/boot # 內核
cp -a /boot/System.map* /mnt/tmp/boot # 內核map
cp -a /boot/config* /mnt/tmp/boot # 內核配置
cp /etc/fstab /mnt/tmp/etc # 文件系統mount信息
mkdir /mnt/tmp/etc/network
cp /etc/network/interfaces /mnt/tmp/etc/network # 網絡配置
cp /etc/hostname /mnt/tmp/etc/ # 本機主機名配置
cp /etc/hosts /mnt/tmp/etc/ # 主機名配置
然後chroot到新系統:
mount -t proc proc /mnt/tmp/proc
chroot /mnt/tmp
passwd @ 設置新口令
10 安裝基本軟件包:
apt-get install aptitude # 安裝包管理工具
apt-get install vim # 安裝vim
apt-get install pppoe pppoeconf sysklogd locales
dpkg-reconfigure locales # 配置locale,一般只需要選擇en.UTF8、zh_CN,* zh_TW.*就可以。
apt-get install libc6-i686 # 使用libc的686優化版本
apt-get install console-data # 安裝鍵位圖
然後進行配置,主要是pppoe與lilo
pppoeconf # 配置ppp
安裝lilo並配置讓它引導/dev/hda2分區:
apt-get install lilo
liloconf
lilo
安裝udev並去掉/dev目錄下的多餘設備文件,只留/dev/console與/dev/null。
apt-get install udev
rm -rf /dev/*
exit
cp -a /dev/console /mnt/tmp/console
cp -a /dev/null /mnt/tmp/null
reboot
11 重啟後進入/dev/hda2, 安裝其它軟件包
apt-get install xserver-xorg-video-fbdev xserver-xorg-input-kdb # 安裝Xwindow驅動,選擇video的驅動很重要,如果不選擇那安裝Xwindow時會需要所有的驅動。
apt-get install roxterm # 安裝X終端
apt-get install xorg # 安裝Xwindow
apt-get install xinit # 安裝startx程序
apt-get install iceweasel # firefox
apt-get install pcmanfm # 輕量級的文件管理器
apt-get install mplayer # 播放器
apt-get install wine # windows程序模擬器
apt-get install fcitx # 中文輸入法
然後再安裝窗口管理器,我使用的是e17,源是:
deb http://debian.alphagemini.org/ unstable main
安裝:
apt-get install e17
如果是使用gnome的話,那用下面命令安裝:
apt-get install gnome-desktop-environment
如果使用kde,那則是
apt-get install kdebase
12. 恢復其它配置文件:
從原來的/etc目錄下恢復備份文件,一般下面文件可能比較有用:
/etc/apt/source.list apt源配置
/etc/X11/xorg.conf Xwindows的配置
~/.xinitrc X啟動腳本
~/.vimrc vimrc配置文件
13. 字體安裝與配置,
安裝, 只需要複製mingliu與tahoma字體就可以。
mkdir /usr/share/fonts/truetype/mingliu
cp <widows>/Fonts/mingliu.ttc /usr/share/fonts/truetype/mingliu
cp <widows>/Fonts/tahoma.ttf /usr/share/fonts/truetype/mingliu
fc-cache -v # 更新字體緩存
配置:
字體配置很簡單,只需要創建/etc/fonts/local.conf配置文件就可以。
/etc/fonts/local.conf配置文件內容如下,是網上找到的,效果還不錯,感謝原作者:
<!-- conf.d/myfont.conf -->
<fontconfig>
<dir>~/.fonts</dir>
<!--
配置粗體中文顯示,要配合freetype-2.1.10,libxft-2.1.7,fontconfig-2.3.X
-->
<match target="font">
<!-- check to see if the font is just regular -->
<test name="weight" compare="less_eq">
<int>100</int>
</test>
<!-- check to see if the pattern requests bold -->
<test target="pattern" name="weight" compare="more_eq">
<int>180</int>
</test>
<!-- set the embolden flag -->
<edit name="embolden" mode="assign">
<bool>true</bool>
</edit>
</match>
<!--
default settings for all fonts.
-->
<match target="font">
<!-- 打開字體的反鋸齒即AA,大號字用AA會更美觀 -->
<edit mode="assign" name="antialias">
<bool>true</bool>
</edit>
<edit mode="assign" name="hintstyle">
<const>hintslight</const>
</edit>
<!-- 打開hint -->
<edit mode="assign" name="hinting">
<bool>true</bool>
</edit>
<!-- 關閉autohint -->
<!--
<edit mode="assign" name="autohint" >
<bool>false</bool>
</edit>
-->
</match>
<!-- 關閉 10到16號字體的AA -->
<!--
<match target="font" >
<test compare="contains" name="lang" >
<string>zh-cn</string>
<string>zh-tw</string>
<string>ja</string>
<string>ko</string>
</test>
<test compare="more_eq" name="pixelsize" qual="any" >
<double>12</double>
</test>
<test compare="less_eq" name="pixelsize" qual="any" >
<double>16</double>
</test>
<edit mode="assign" name="antialias" >
<bool>false</bool>
</edit>
</match>
-->
<!-- 解決英文字體間距過寬 -->
<match target="font">
<test target="pattern" name="lang" compare="contains">
<string>zh-tw</string>
<string>zh-cn</string>
<string>ja</string>
<string>ko</string>
</test>
<edit name="spacing">
<const>proportional</const>
</edit>
<edit name="globaladvance">
<bool>false</bool>
</edit>
</match>
<!--
設定中文最小字號,使得小字的中文美觀
-->
<match target="font">
<test name="family" qual="any">
<string>mingliu</string>
<string>Nmingliu</string>
<string>SimHei</string>
<string>AR PL ShanHeiSun Uni</string>
<string>AR PL ZenKai Uni</string>
<string>AR PL New Sung</string>
<string>FZSongTi</string>
<string>FZMingTiB</string>
<string>FangSong_GB2312</string>
<string>KaiTi_GB2312</string>
</test>
<test compare="more_eq" name="pixelsize">
<int>5</int>
</test>
<test compare="less_eq" name="pixelsize">
<int>11</int>
</test>
<edit compare="eq" name="pixelsize">
<int>12</int>
</edit>
</match>
<!--
use english fonts instead of chinese fonts' letters
-->
<match target="pattern">
<test name="family">
<string>mingliu</string>
<string>細明體</string>
<string>AR PL ShanHeiSun Uni</string>
<string>PMingLiU</string>
<string>新細明體</string>
</test>
<edit binding="strong" mode="prepend" name="family">
<string>Tahoma</string>
<string>mingliu</string>
<string>Nimbus Roman No9 L</string>
</edit>
</match>
<!--
<match target="pattern">
<test name="family">
<string>Nmingliu</string>
<string>新細明體</string>
<string>MingLiU</string>
<string>細明體</string>
</test>
<edit binding="strong" mode="prepend" name="family">
<string>Courier New</string>
<string>Cumberland AMT</string>
<string>Nimbus Mono L</string>
</edit>
</match>
-->
<!--
把serif ,sans,monospace的family(字體族)重新排序,適應中文用戶的用字習慣
-->
<alias>
<family>serif</family>
<prefer>
<family>Times New Roman</family>
<family>mingliu</family>
<family>Nimbus Roman No9 L</family>
<family>Luxi Serif</family>
<family>Times</family>
<family>Bitstream Vera Serif</family>
<family>WenQuanYi Bitmap Song</family>
<family>AR PL ShanHeiSun Uni</family>
<family>AR PL ZenKai Uni</family>
<family>AR PL New Sung</family>
<family>FZSongTi</family>
<family>FZMingTiB</family>
<family>Kochi Mincho</family>
<family>AR PL SungtiL GB</family>
<family>AR PL Mingti2L Big5</family>
<family>Baekmuk Batang</family>
</prefer>
</alias>
<alias>
<family>Mulberry</family>
<prefer>
<family>Monaco</family>
<family>SimHei</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>Helvetica</family>
<family>Verdana</family>
<family>Arial</family>
<family>Tahoma</family>
<family>Bitstream Vera Sans</family>
<family>mingliu</family>
<family>WenQuanYi Bitmap Song</family>
<family>AR PL ShanHeiSun Uni</family>
<family>AR PL ZenKai Uni</family>
<family>AR PL New Sung</family>
<family>FZSongTi</family>
<family>FZMingTiB</family>
<family>Kochi Gothic</family>
<family>AR PL KaitiM GB</family>
<family>AR PL KaitiM Big5</family>
<family>Baekmuk Dotum</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Courier</family>
<family>Courier New</family>
<family>Andale Mono</family>
<family>Luxi Mono</family>
<family>Nimbus Mono L</family>
<family>Bitstream Vera Sans Mono</family>
<family>Nmingliu</family>
<!-- han (zh-cn,zh-tw) -->
<family>WenQuanYi Bitmap Song</family>
<family>AR PL ShanHeiSun Uni</family>
<family>AR PL ZenKai Uni</family>
<family>AR PL New Sung</family>
<family>FZSongTi</family>
<family>FZMingTiB</family>
<family>Kochi Gothic</family>
<family>AR PL KaitiM GB</family>
<family>Baekmuk Dotum</family>
</prefer>
</alias>
</fontconfig>
附自用的vimrc.
放到/etc/vim/vimrc.local文件中就可以全局生效
需要下載ps_color與oceandeep顏色
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
if has("win32")
source $VIMRUNTIME/mswin.vim
"behave mswin
endif
behave xterm
set ffs=unix,dos
set fencs=utf-8,cp936,ucs-bom,default,latin1
set langmenu=none " 使用英文菜單
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
" 1 height windows
"set winminheight=1
set guicursor=a:blinkon0 " 停止閃爍
if has("gui_running")
" win下FixedSys的字體比較好看, unix下bitstream不錯
" set guifont=Bitstream_Vera_Sans_Mono:h12:cANSI
if has("win32")
set guifont=Fixedsys:h12:cGB2312
else
set guifont=Bitstream\ Vera\ Sans\ Mono\ 16
endif
set guioptions-=T " 去掉工具欄,我喜歡顯示的範圍更大的
set guioptions-=m " 去掉菜單,我喜歡顯示的範圍更大的
set guioptions-=l
set guioptions-=L
set guioptions-=r
set guioptions-=R
" No icky toolbar, menu or scrollbars in the GUI
"if has('gui')
" set guioptions-=m
" set guioptions-=T
" set guioptions-=l
" set guioptions-=L
" set guioptions-=r
" set guioptions-=R
"end
colorscheme oceandeep
" desert " 背景顏色
else
set background=dark
colorscheme ps_color "zellner
endif
"-------------------------------------------------------------------------------
" Moving cursor to other windows
"
" shift down : change window focus to lower one (cyclic)
" shift up : change window focus to upper one (cyclic)
" shift left : change window focus to one on left
" shift right : change window focus to one on right
"-------------------------------------------------------------------------------
"
nmap <s-down> <c-w>w
nmap <s-up> <c-w>W
nmap <s-left> <c-w>h
nmap <s-right> <c-w>l
set autoread " read open files again when changed outside Vim
" set autowrite " write a modified buffer on each :next , ...
set browsedir =current " which directory to use for the file browser
"set nowrap " 顯示時不自動換行, 看個人愛好, 注掉也不錯
"-------------------------------------------------------------------------------
" Change the working directory to the directory containing the current file
"-------------------------------------------------------------------------------
if has("autocmd")
" 如果使用cscope或是ctags的話, 最好不要自動切換目錄, 不然標誌無法定位
" autocmd BufEnter * :lcd %:p:h
endif
"-------------------------------------------------------------------------------
" Filename completion
"
" wildmenu : command-line completion operates in an enhanced mode
" wildignore : A file that matches with one of these
" patterns is ignored when completing file or directory names.
"-------------------------------------------------------------------------------
"
set wildmenu
set wildignore=*.svn,*.svn-base,*.bak,*.o,*.e,*~
set suffixes=.svn
" Allow edit buffers to be hidden
set hidden
if v:version >= 700
set stal=1 " 當打開多個tab時顯示tab,如果只有一個則不顯示,tab只在7.0中有效
endif
" Highlight matching parens
"set showmatch
if v:version >= 700
"set cursorline " 高亮當前行,在oceandeep佈局下顯示的不是很清楚,
"去掉
endif
set et " TODO 刪除
set ch=2 " Make command line two lines high
set mousehide " Hide the mouse when typing text
let c_comment_strings=1 " I like highlighting strings inside C comments
set formatoptions=tcrqn2mB
set ts=8 " tab是8空格
set sw=4 "shift width,indent時的值是4格,
set sts=4 " soft tab是4空格, 按一次tab時也是4格, 使用space代替
set bs=2 " 退格鍵的模式
set lsp=0 " space it out a little more (easier to read)
set vb t_vb= " set visual bell and disable screen flash
set ru " 在下面顯示標尺
set grepprg=grep\ -nH " 使用grep查找, grep包括在unxutils中
"""""""""""""""""""""""""""""""""""""""
" 查找的配置
"""""""""""""""""""""""""""""""""""""""
set incsearch " use incremental search
set ic " 查找時忽略大小寫
set is " 增量查找
set scs " 查找時智能大小寫
set hlsearch " hlsearch, 高亮顯示查找結果
" Wrap on these
set whichwrap+=<,>,[,]
"""""""""""""""""""""""""""""""""""""""
" 自動補全功能
" 編程快捷鍵, 按#i 空格時, 自動變成#include
"""""""""""""""""""""""""""""""""""""""
iab #i #include
iab #d #define
iab #e #endif
"""""""""""""""""""""""""""""""""""""""
" 設置使用cscope, 並設置自動查找tags文件的目錄
"""""""""""""""""""""""""""""""""""""""
set cst
set csto=1
set tags=./tags,../tags,../../tags,../../../tags
set cspc=3 " show file path's last three part
"""""""""""""""""""""""""""""""""""""""
" 配置命令模式下的快鍵鍵
"""""""""""""""""""""""""""""""""""""""
" Tlist :taglist, 在左邊窗口顯示文件中的函數名與定義名
" WMToggle 打開/關閉 資源管理器和buf 管理器
" zO,zC,zR,zM 折行功能
" :cn grep查找到結果時進入下一個結果
map <F1> :Tlist<cr>
map <F2> :WMToggle<cr>
map <F3> zO
map <F4> zc
map <F5> zR
map <F6> zM
map <F7> :cn<CR>
"""""""""""""""""""""""""""""""""""""""
" 配置備份和交換文件目錄
" 默認vim會把這些文件放在當時目錄下, 看起來比較亂
"""""""""""""""""""""""""""""""""""""""
set backup " enable backup and define the backup file
set backupext=.bak
" 設置swap文件的目錄到dir
"設置備份文件的目錄到backupdir 我不喜歡看到每個目錄下都有備份 因為一般備份用不到
if has("unix")
set dir=/tmp
set backupdir=/tmp
else
set dir=D:\tmp\vim\swap
set backupdir=D:\tmp\vim\bak
endif
"""""""""""""""""""""""""""""""""""""""
" 折行配置
"""""""""""""""""""""""""""""""""""""""
" 根據語法折行, 如c/c++中就是{}
if v:version >= 700
set foldmethod=syntax " marker,folder模式為語法
else
" vim63中不支持根據語法折行
set foldmethod=indent
endif
set foldlevel=100 " Don't autofold anything (but I can still fold manually)
set foldopen-=search " don't open folds when you search into them
set foldopen-=undo " don't open folds when you undo stuff
"""""""""""""""""""""""""""""""""""""""
" Perl
"""""""""""""""""""""""""""""""""""""""
let perl_extended_vars=1 " highlight advanced perl vars inside strings
""""""""""""""""""""""""""""""""""""""
" 網上下載
""""""""""""""""""""""""""""""""""""""
" Nice statusbar
set laststatus=2
set statusline=
set statusline+=%2*%-3.3n%0*\ " buffer number
set statusline+=%f\ " file name
set statusline+=%h%1*%m%r%w%0* " flags
"set statusline+=\[%{strlen(&ft)?&ft:'none'}, " filetype
"set statusline+=%{&encoding}, " encoding
"set statusline+=%{&fileformat}] " file format
if filereadable(expand("$VIM/vimfiles/plugin/vimbuddy.vim"))
set statusline+=\ %{VimBuddy()} " vim buddy
endif
set statusline+=%= " right align
set statusline+=%2*0x%-4B\ " current char
set statusline+=%-8.(%l,%c%V%)\ %<%P " offset
" special statusbar for special windows
if has("autocmd")
au FileType qf
\ if &buftype == "quickfix" |
\ setlocal statusline=%2*%-3.3n%0* |
\ setlocal statusline+=\ \[Compiler\ Messages\] |
\ setlocal statusline+=%=%2*\ %<%P |
\ endif
fun! <SID>FixMiniBufExplorerTitle()
if "-MiniBufExplorer-" == bufname("%")
setlocal statusline=%2*%-3.3n%0*
setlocal statusline+=\[Buffers\]
setlocal statusline+=%=%2*\ %<%P
endif
endfun
au BufWinEnter *
\ let oldwinnr=winnr() |
\ windo call <SID>FixMiniBufExplorerTitle() |
\ exec oldwinnr . " wincmd w"
endif
" Nice window title
if has('title') && (has('gui_running') || &title)
set titlestring=
set titlestring+=%f\ " file name
set titlestring+=%h%m%r%w " flags
set titlestring+=\ -\ %{v:progname} " program name
endif
" If possible, try to use a narrow number column.
if v:version >= 700
try
setlocal numberwidth=3
catch
endtry
endif
" Better include path
set path+=src/
" Show tabs and trailing whitespace visually
"if (&termencoding == "utf-8") || has("gui_running")
" if v:version >= 700
" set list listchars=tab:?·,trail:·,extends:…,nbsp:?
" else
" set list listchars=tab:?·,trail:·,extends:…
" endif
"else
" if v:version >= 700
" set list listchars=tab:>-,trail:.,extends:>,nbsp:_
" else
" set list listchars=tab:>-,trail:.,extends:>
" endif
"endif
set fillchars=fold:-
" "-----------------------------------------------------------------------
" " completion
" "-----------------------------------------------------------------------
" set dictionary=/usr/share/dict/words
"""""""""""""""""""""""""""""""""""""""
" 插件配置
"""""""""""""""""""""""""""""""""""""""
" taglist, 顯示在右邊
let Tlist_Use_Right_Window=0
"let Tlist_WinWidth = 20
"let Tlist_Inc_Winwidth = 0
let Tlist_Enable_Fold_Column = 0
let g:defaultExplorer=0
"-----------------------------------------------------------------------
" plugin / script / app settings
"-----------------------------------------------------------------------
if has("eval")
" Perl specific options
let perl_include_pod=1
let perl_fold=1
let perl_fold_blocks=1
" Vim specific options
let g:vimsyntax_noerror=1
let g:vimembedscript=0
" c specific options
let g:c_gnu=1
let g:c_no_curly_error=1
" eruby options
au Syntax * hi link erubyRubyDelim Directory
" Settings for taglist.vim
let Tlist_Use_Right_Window=1
let Tlist_Auto_Open=0
let Tlist_Enable_Fold_Column=0
let Tlist_Compact_Format=1
let Tlist_WinWidth=28
let Tlist_Exit_OnlyWindow=1
let Tlist_File_Fold_Auto_Close = 1
" nnoremap <silent> <F9> :Tlist<CR>
" " Settings minibufexpl.vim
" let g:miniBufExplModSelTarget = 1
" let g:miniBufExplWinFixHeight = 1
" let g:miniBufExplWinMaxSize = 1
" " let g:miniBufExplForceSyntaxEnable = 1
" Settings for showmarks.vim
if has("gui_running")
let g:showmarks_enable=1
else
let g:showmarks_enable=0
let loaded_showmarks=1
endif
let g:showmarks_include="abcdefghijklmnopqrstuvwxyz"
if has("autocmd")
fun! <SID>FixShowmarksColours()
if has('gui')
hi ShowMarksHLl gui=bold guifg=#a0a0e0 guibg=#2e2e2e
hi ShowMarksHLu gui=none guifg=#a0a0e0 guibg=#2e2e2e
hi ShowMarksHLo gui=none guifg=#a0a0e0 guibg=#2e2e2e
hi ShowMarksHLm gui=none guifg=#a0a0e0 guibg=#2e2e2e
hi SignColumn gui=none guifg=#f0f0f8 guibg=#2e2e2e
endif
endfun
if v:version >= 700
autocmd VimEnter,Syntax,ColorScheme * call <SID>FixShowmarksColours()
else
autocmd VimEnter,Syntax * call <SID>FixShowmarksColours()
endif
endif
" Settings for explorer.vim
let g:explHideFiles='^\.'
" Settings for netrw
let g:netrw_list_hide='^\.,\~$'
" Settings for :TOhtml
let html_number_lines=1
let html_use_css=1
let use_xhtml=1
" cscope settings
if has('cscope')
" && filereadable("/usr/bin/cscope")
set csto=0
set cscopetag
set nocsverb
if filereadable("cscope.out")
cs add cscope.out
endif
set csverb
let x = "sgctefd"
while x != ""
let y = strpart(x, 0, 1) | let x = strpart(x, 1)
exec "nmap <C-j>" . y . " :cscope find " . y .
\ " <C-R>=expand(\"\<cword\>\")<CR><CR>"
exec "nmap <C-j><C-j>" . y . " :scscope find " . y .
\ " <C-R>=expand(\"\<cword\>\")<CR><CR>"
endwhile
nmap <C-j>i :cscope find i ^<C-R>=expand("<cword>")<CR><CR>
nmap <C-j><C-j>i :scscope find i ^<C-R>=expand("<cword>")<CR><CR>
endif
endif
""""""""""""""""""""""""""""""""""""""""""""""""""""
" 其它不用的
""""""""""""""""""""""""""""""""""""""""""""""""""""
" turn off any existing search
if has("autocmd")
" au VimEnter * nohls
endif
" set showfulltag " Show full tags when doing search completion
" Speed up macros
" set lazyredraw
" Try to show at least three lines and two columns of context when
" scrolling
" set scrolloff=3
" set sidescrolloff=2
"-------------------------------------------------------------------------------
" Use of dictionaries
" "-----------------------------------------------------------------------
" " final commands
" "-----------------------------------------------------------------------
" " mio
" let Tlist_Ctags_Cmd="/usr/bin/exuberant-ctags"
" " plegado ident para python
" au FileType python set foldmethod=indent
" " plegado syntax para sgml,htmls,xml y xsl
" au Filetype html,xml,xsl,sgml,docbook
" " explorador vertical
" let g:explVertical=1
" " define leader como =
" let mapleader = "="
"
" map <S-F2> :vsplit ~/.vim/ref_full.vim<CR>
" map <F2> :11vsplit ~/.vim/ref.vim<CR>
" map <F3> :Sexplore /home/bass/<CR>
" map <S-F3> :2split ~/.vim/fun_ref.vim<CR>
" map <F4> :set nu<CR>
" map <S-F4> :set nu!<CR>
" map <F5> ggVGg?
" map <F6> :set encoding=utf-8<CR> | :set fenc=utf-8<CR>
" map <S-F6> :set encoding=iso8859-15<CR> | :set fenc=iso8859-15<CR>
" map <F7> :SpellProposeAlternatives<CR>
" map <S-F7> :SpellCheck<CR>
" map <C-F7> :let spell_language_list = "english,spanish"
" nnoremap <silent> <F8> :Tlist<CR>
" nnoremap <silent> <S-F8> :TlistSync<CR>
" map <F11> !!date<CR>
" map <F12> :TC<CR>
" nmap :X
" nmap :W :w
" nmap :Q :q
" noremap <Leader>rg :color relaxedgreen<CR>
" noremap <Leader>ip :color inkpot<CR>
"
" " CVS
" nmap <leader>cadd <Plug>CVSAdd
" nmap <leader>cci <Plug>CVSCommit
" nmap <leader>clog <Plug>CVSLog
" map <leader>cre <Plug>CVSRevert
" nmap <leader>cup <Plug>CVSUpdate
" nmap <leader>cdiff <Plug>CVSDiff
"
" " Spell
" let spell_executable = "aspell"
" let spell_language_list = "spanish,english"
"
" " Comentiffy
" let g:EnhCommentifyMultiPartBlocks = 'yes'
" let g:EnhCommentifyAlignRight = 'yes'
" " let g:EnhCommentifyRespectIndent = 'Yes'
" let g:EnhCommentifyPretty = 'Yes'
" " let g:EnhCommentifyUserBindings = 'yes'
"-----------------------------------------------------------------------
" vim: set shiftwidth=4 softtabstop=4 expandtab tw=72 :
"
" dictionary : List of file names that are used to lookup words
" for keyword completion commands
" complete : search the files defined by the 'dictionary' option
"-------------------------------------------------------------------------------
"
"set complete+=k
" "-----------------------------------------------------------------------
" " autocmds
" "-----------------------------------------------------------------------
"
" if has("eval")
"
" " If we're in a wide window, enable line numbers.
" fun! <SID>WindowWidth()
" if winwidth(0) > 90
" setlocal foldcolumn=1
" setlocal number
" else
" setlocal nonumber
" setlocal foldcolumn=0
" endif
" endfun
" endif
"
" " content creation
" if has("autocmd")
" augroup content
" autocmd!
"
" autocmd BufNewFile *.rb 0put ='# vim: set sw=4 sts=4 et tw=80 :' |
" \ 0put ='#!/usr/bin/ruby' | set sw=4 sts=4 et tw=80 |
" \ norm G
"
" autocmd BufNewFile *.hh 0put ='/* vim: set sw=4 sts=4 et foldmethod=syntax : */' |
" \ 1put ='' | call MakeIncludeGuards() |
" \ 5put ='#include \"config.h\"' |
" \ set sw=4 sts=4 et tw=80 | norm G
"
" autocmd BufNewFile *.cc 0put ='/* vim: set sw=4 sts=4 et foldmethod=syntax : */' |
" \ 1put ='' | 2put ='' | call setline(3, '#include "' .
" \ substitute(expand("%:t"), ".cc$", ".hh", "") . '"') |
" \ set sw=4 sts=4 et tw=80 | norm G
"
" autocmd BufNewFile configure.ac
" \ 0put ='dnl vim: set sw=8 sts=8 noet :' |
" \ $put ='' |
" \ call setline(line('$'), 'AC_INIT([' . substitute(expand('%:p:h'),
" \ '^.\{-}/\([^/]\+\)\(/trunk\)\?$', '\1', '') . '], [0.0])') |
" \ $put ='AC_PREREQ(2.5)' |
" \ $put ='AC_CONFIG_SRCDIR([])' |
" \ $put ='AC_CONFIG_AUX_DIR(config)' |
" \ $put ='AM_INIT_AUTOMAKE(1.9)' |
" \ $put ='' |
" \ $put ='dnl check for required programs' |
" \ $put ='AC_PROG_CXX' |
" \ $put ='AC_PROG_INSTALL' |
" \ $put ='AC_PROG_LN_S' |
" \ $put ='AC_PROG_RANLIB' |
" \ $put ='AC_PROG_MAKE_SET' |
" \ $put ='' |
" \ $put ='dnl output' |
" \ $put ='AM_CONFIG_HEADER(config.h)' |
" \ $put ='AC_OUTPUT(' |
" \ $put =' Makefile' |
" \ $put =' src/Makefile' |
" \ $put =' )' |
" \ set sw=8 sts=8 noet |
" \ norm ggjjjjf]
"
" autocmd BufNewFile autogen.bash
" \ 0put ='#!/usr/bin/env bash' |
" \ 1put ='# vim: set sw=4 sts=4 et tw=80 :' |
" \ $put ='run() {' |
" \ $put ='echo \">>> $@\"' |
" \ $put =' if ! $@ ; then' |
" \ $put =' echo \"oops!\" 1>&2' |
" \ $put =' exit 127' |
" \ $put =' fi' |
" \ $put ='}' |
" \ $put ='' |
" \ $put ='get() {' |
" \ $put =' type ${1}-${2} &>/dev/null && echo ${1}-${2} && return' |
" \ $put =' type ${1}${2//.} &>/dev/null && echo ${1}${2//.} && return' |
" \ $put =' type ${1} &>/dev/null && echo ${1} && return' |
" \ $put =' echo \"Could not find ${1} ${2}\" 1>&2' |
" \ $put =' exit 127' |
" \ $put ='}' |
" \ $put ='' |
" \ $put ='run mkdir -p config' |
" \ $put ='run $(get libtoolize 1.5 ) --copy --force --automake' |
" \ $put ='rm -f config.cache' |
" \ $put ='run $(get aclocal 1.9 )' |
" \ $put ='run $(get autoheader 2.59 )' |
" \ $put ='run $(get autoconf 2.59 )' |
" \ $put ='run $(get automake 1.9 ) -a --copy' |
" \ set sw=4 sts=4 et tw=80 |
" \ norm gg=Ggg
"
" autocmd BufNewFile Makefile.am
" \ 0put ='CLEANFILES = *~' |
" \ if (! filereadable(expand("%:p:h:h") . '/Makefile.am')) |
" \ $put ='MAINTAINERCLEANFILES = Makefile.in configure config/* aclocal.m4 \' |
" \ $put ='' |
" \ call setline(line('$'), "\t\t\tconfig.h config.h.in") |
" \ $put ='AUTOMAKE_OPTIONS = foreign dist-bzip2' |
" \ $put ='EXTRA_DIST = autogen.bash' |
" \ else |
" \ $put ='MAINTAINERCLEANFILES = Makefile.in' |
" \ endif
"
" augroup END
" endif
"
" "-----------------------------------------------------------------------
" " mappings
" "-----------------------------------------------------------------------
"
" nmap <silent> <S-Right> :bnext<CR>
"
" " v_K is really really annoying
" vmap K k
"
" " Delete a buffer but keep layout
" if has("eval")
" command! Kwbd enew|bw #
" nmap <C-w>! :Kwbd<CR>
" endif
"
" " quickfix things
" nmap <Leader>cwc :cclose<CR>
" nmap <Leader>cwo :botright copen 5<CR><C-w>p
" nmap <Leader>cn :cnext<CR>
"
" " Annoying default mappings
" inoremap <S-Up> <C-o>gk
" inoremap <S-Down> <C-o>gj
" noremap <S-Up> gk
" noremap <S-Down> gj
"
" " Make <space> in normal mode go down a page rather than left a
" " character
" noremap <space> <C-f>
"
" " Useful things from inside imode
" inoremap <C-z>w <C-o>:w<CR>
" inoremap <C-z>q <C-o>gq}<C-o>k<C-o>$
"
" " Commonly used commands
" "nmap <silent> <F3> :silent nohlsearch<CR>
" "imap <silent> <F3> <C-o>:silent nohlsearch<CR>
" "nmap <F4> :Kwbd<CR>
" "nmap <F5> <C-w>c
" "nmap <F7> :make check<CR>
" "nmap <F8> :make<CR>
" "nmap <F10> :!svn update<CR>
" "nmap <F11> :!svn status \| grep -v '^?' \| sort -k2<CR>
"
" " Insert a single char
" noremap <Leader>i i<Space><Esc>r
"
" " Split the line
" nmap <Leader>n \i<CR>
"
" " Pull the following line to the cursor position
" noremap <Leader>J :s/\%#\(.*\)\n\(.*\)/\2\1<CR>
"
" " In normal mode, jj escapes
" inoremap jj <Esc>
"
" " Kill line
" noremap <C-k> "_dd
"
" " Select everything
" noremap <Leader>gg ggVG
"
" " Reformat everything
" noremap <Leader>gq gggqG
"
" " Reformat paragraph
" noremap <Leader>gp gqap
"
" " Clear lines
" noremap <Leader>clr :s/^.*$//<CR>:nohls<CR>
"
" " Delete blank lines
" noremap <Leader>dbl :g/^$/d<CR>:nohls<CR>
"
" " Enclose each selected line with markers
" noremap <Leader>enc :<C-w>execute
" \ substitute(":'<,'>s/^.*/#&#/ \| :nohls", "#", input(">"), "g")<CR>
"
" " Enable fancy % matching
" if has("eval")
" runtime! macros/matchit.vim
" endif
" "
" " " q: sucks
" " nmap q: :q
" "
" " " set up some more useful digraphs
" " if has("digraphs")
" " digraph ., 8230 " ellipsis (…)
" " endif
"
" if has("eval")
" " GNU format changelog entry
" fun! MakeChangeLogEntry()
" norm gg
" /^\d
" norm 2O
" norm k
" call setline(line("."), strftime("%Y-%m-%d") .
" \ " J. Alberto Suarez Lopez <bass@gentoo.org>")
" norm 2o
" call setline(line("."), "\t* ")
" norm $
" endfun
" noremap <Leader>cl :call MakeChangeLogEntry()<CR>
"
" " command aliases, can't call these until after cmdalias.vim is loaded
" au VimEnter * if exists("loaded_cmdalias") |
" \ call CmdAlias("mkdir", "!mkdir") |
" \ call CmdAlias("cvs", "!cvs") |
" \ call CmdAlias("svn", "!svn") |
" \ call CmdAlias("commit", "!svn commit -m \"") |
" \ call CmdAlias("upload", "make upload") |
" \ endif
" endif
"
" " super i_c-y / i_c-e
" if v:version >= 700 && has("eval")
" fun! SuperYank(offset)
" let l:cursor_pos = col(".")
" let l:this_line = line(".")
" let l:source_line = l:this_line + a:offset
" let l:this_line_text = getline(l:this_line)
" let l:source_line_text = getline(l:source_line)
" let l:add_text = ""
"
" let l:motion = "" . nr2char(getchar())
" if -1 != match(l:motion, '\d')
" let l:count = 0
" while -1 != match(l:motion, '\d')
" let l:count = l:count * 10 + l:motion
" let l:motion = "" . nr2char(getchar())
" endwhile
" else
" let l:count = 1
" endif
"
" if l:motion == "$"
" let l:add_text = strpart(l:source_line_text, l:cursor_pos - 1)
" elseif l:motion == "w"
" let l:add_text = strpart(l:source_line_text, l:cursor_pos - 1)
" let l:add_text = substitute(l:add_text,
" \ '^\(\s*\%(\S\+\s*\)\{,' . l:count . '}\)\?.*', '\1', '')
" elseif l:motion == "f" || l:motion == "t"
" let l:add_text = strpart(l:source_line_text, l:cursor_pos - 1)
" let l:char = nr2char(getchar())
" let l:pos = matchend(l:add_text,
" \ '^\%([^' . l:char . ']\{-}' . l:char . '\)\{' . l:count . '}')
" if -1 != l:pos
" let l:add_text = strpart(l:add_text, 0, l:motion == "f" ? l:pos : l:pos - 1)
" else
" let l:add_text = ''
" endif
" else
" echo "Unknown motion: " . l:motion
" endif
"
" if l:add_text != ""
" let l:new_text = strpart(l:this_line_text, 0, l:cursor_pos - 1) .
" \ l:add_text . strpart(l:this_line_text, l:cursor_pos - 1)
" call setline(l:this_line, l:new_text)
" call cursor(l:this_line, l:cursor_pos + strlen(l:add_text))
" endif
" endfun
"
" inoremap <C-g>y <C-\><C-o>:call SuperYank(-1)<CR>
" inoremap <C-g>e <C-\><C-o>:call SuperYank(1)<CR>
" endif
"
" " " tab completion
" " if has("eval")
" " function! CleverTab()
" " if strpart(getline('.'), 0, col('.') - 1) =~ '^\s*$'
" " return "\<Tab>"
" " else
" " return "\<C-N>"
" " endif
" " endfun
" " inoremap <Tab> <C-R>=CleverTab()<CR>
" " inoremap <S-Tab> <C-P>
" " endif
"
" " "-----------------------------------------------------------------------
" " " abbreviations
" " "-----------------------------------------------------------------------
" "
" " if has("eval") && has("autocmd")
" " fun! <SID>abbrev_cpp()
" " iabbrev <buffer> raise throw
" " iabbrev <buffer> jci const_iterator
" " iabbrev <buffer> jcl class
" " iabbrev <buffer> jco const
" " iabbrev <buffer> jdb \bug
" " iabbrev <buffer> jde \throws
" " iabbrev <buffer> jdf /** \file<CR><CR>/<Up>
" " iabbrev <buffer> jdg \ingroup
" " iabbrev <buffer> jdn /** \namespace<CR><CR>/<Up>
" " iabbrev <buffer> jdp \param
" " iabbrev <buffer> jdt \test
" " iabbrev <buffer> jdx /**<CR><CR>/<Up>
" " iabbrev <buffer> jit iterator
" " iabbrev <buffer> jns namespace
" " iabbrev <buffer> jpr protected
" " iabbrev <buffer> jpu public
" " iabbrev <buffer> jpv private
" " iabbrev <buffer> jsl std::list
" " iabbrev <buffer> jsm std::map
" " iabbrev <buffer> jss std::string
" " iabbrev <buffer> jsv std::vector
" " iabbrev <buffer> jty typedef
" " iabbrev <buffer> jun using namespace
" " iabbrev <buffer> jvi virtual
" " endfun
" "
" " augroup abbreviations
" " autocmd!
" " autocmd FileType cpp :call <SID>abbrev_cpp()
" " augroup END
" " endif
"
" "-----------------------------------------------------------------------
" " special less.sh and man modes
" "-----------------------------------------------------------------------
"
" if has("eval") && has("autocmd")
" fun! <SID>check_pager_mode()
" if exists("g:loaded_less") && g:loaded_less
" " we're in vimpager / less.sh / man mode
" set laststatus=0
" set ruler
" set foldmethod=manual
" set foldlevel=99
" set nolist
" endif
" endfun
" autocmd VimEnter * :call <SID>check_pager_mode()
" endif
vim插件:
DoxygenToolkit.vim ox會自動產生函數註釋
c.vim :c文件註釋
DrawItPlugin.vim :用文本畫圖
winmanager.vim :文件管理器
bufexplorer.vim :打開的文件查看器
a.vim :在cpp/h文件中進行快速切換
matchit.vim :超級匹配,如html標誌匹配
taglist.vim :c函數列表
vim插件:
DoxygenToolkit.vim 會自動產生函數註釋
c.vim :c文件註釋
DrawItPlugin.vim :用文本畫圖
winmanager.vim :文件管理器
bufexplorer.vim :打開的文件查看器
a.vim :在cpp/h文件中進行快速切換
matchit.vim :超級匹配,如html標誌匹配
taglist.vim :c函數列表