Setting up ViM: Difference between revisions
From MoodleDocs
No edit summary |
No edit summary |
||
Line 41: | Line 41: | ||
set errorformat=%m\ in\ %f\ on\ line\ %l | set errorformat=%m\ in\ %f\ on\ line\ %l | ||
</pre> | |||
== File encoding and decoding == | |||
<pre> | |||
set fileencodings=ucs-bom,utf-8,gbk,big5,latin1 | |||
set termencoding=utf-8,gbk | |||
if has ('multi_byte') && v:version > 601 | |||
if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)' | |||
set ambiwidth=double | |||
endif | |||
endif | |||
</pre> | |||
== Status Line == | |||
<pre> | |||
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P | |||
</pre> | </pre> | ||
== Ctags == | == Ctags == | ||
See the [[ctags|Ctags Article]] for details on how to setup ctags usage with moodle and vim | See the [[ctags|Ctags Article]] for details on how to setup ctags usage with moodle and vim |
Revision as of 05:37, 27 May 2008
Setting up Vim for Moodle Development
There are many powerful features available in vim, here are a few tips to ensure you get powerful use out of vim with moodle development
Indentation
Moodle Coding Guidelines state that indentation should be spaces of 4 spaces (not Tabs). Some .vimrc options will help you adhere to these guidelines with ease:
" insert space characters whenever the tab key is presse set expandtab " insert 4 spaces characters when tab key is pressed set tabstop=4 " insert 4 spaces wen autoindent indents set shiftwidth=4 " automatically indent files set autoindent " Do smart indentation depending on code syntax (e.g. change after { }, keywords etc) set smartindent
Syntax Highlighting
Recent versions of vim have robust syntax highlighting for php. In order to switch syntax highlighting on add the following to your .vimrc:
" set syntax highliging on syntax on
Other Useful vimrc settings
" show a ruler with line number, % through file on status line set ruler " show line number set nu " PHP syntax check set makeprg=php\ -l\ % set errorformat=%m\ in\ %f\ on\ line\ %l
File encoding and decoding
set fileencodings=ucs-bom,utf-8,gbk,big5,latin1 set termencoding=utf-8,gbk if has ('multi_byte') && v:version > 601 if v:lang =~? '^\(zh\)\|\(ja\)\|\(ko\)' set ambiwidth=double endif endif
Status Line
set statusline=%<%f\ %h%m%r%=%k[%{(&fenc==\"\")?&enc:&fenc}%{(&bomb?\",BOM\":\"\")}]\ %-14.(%l,%c%V%)\ %P
Ctags
See the Ctags Article for details on how to setup ctags usage with moodle and vim