| PostgreSQL 7.4 文檔 | ||||
|---|---|---|---|---|
| Prev | Fast Backward | Fast Forward | Next | |
代碼格式使用每個制表符(tab)4列的空白, 目前是保留制表符狀態(也就是說制表符不被展開為空白)。 每個邏輯縮進層次都是更多的一個 tab。布局規則(花括弧定位等)遵循 BSD 傳統。
雖然提交的補丁並不需要我那全遵循這些格式化規則,我們最好還是這麼做。 你的代碼將會被 pgindent 處理,雖然這樣做不會讓它看起來比其它的格式化習慣更好看。
對于使用 Emacs 的人,把下面行(或者類似的東西)增加到你的 ~/.emacs 初始化文件裡面去:
;; check for files with a path containing "postgres" or "pgsql"
(setq auto-mode-alist
(cons '("\\(postgres\\|pgsql\\).*\\.[ch]\\'" . pgsql-c-mode)
auto-mode-alist))
(setq auto-mode-alist
(cons '("\\(postgres\\|pgsql\\).*\\.cc\\'" . pgsql-c-mode)
auto-mode-alist))
(defun pgsql-c-mode ()
;; sets up formatting for PostgreSQL C code
(interactive)
(c-mode)
(setq-default tab-width 4)
(c-set-style "bsd") ; set c-basic-offset to 4, plus other stuff
(c-set-offset 'case-label '+) ; tweak case indent to match PG custom
(setq indent-tabs-mode t)) ; make sure we keep tabs when indenting
對于 vi,你的 ~/.vimrc 或者相當的文件應該包含下面的東西:
set tabstop=4
或者在 vi 裡面鍵入
:set ts=4
文本瀏覽工具 more 和 less 可以用下面命令調用
more -x4 less -x4
這樣就可以讓他們正確顯示 tab 鍵。