Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

User:David Mudrak/vimrc

From MoodleDocs
" TAGS
set tags=tags,../tags,../../tags,../../../tags,../../../../tags,../../../../../tags,../../../../../../tags,../../../../../../../tags

" remap ctrl+] to use cscope
autocmd BufEnter *.php set cst
" but try standard ctags for the unique match first
set csto=1

" backup handling
set nobackup
set writebackup

" do not highlight search result
set nohlsearch

" do not generate fold even when a syntax
set nofoldenable

" filetype-specific issues
autocmd BufEnter *.tex setlocal textwidth=80
autocmd BufNewFile,BufRead *.cpy,*.vpy setf python
autocmd BufNewFile,BufRead *.cpt,*.pt setf html
autocmd BufEnter */vimperator-*.tmp setlocal linebreak
autocmd BufNewFile,BufRead,BufRead COMMIT_EDITMSG,*/vimperator-*.tmp setlocal spell

" display the filename in the screen/window title and set it back to "bash" on exit
autocmd BufEnter * let &titlestring = expand("%:t")
let &titleold="bash"
if &term == "screen"
  set t_ts=�k
  set t_fs=�\
endif
if &term == "screen" || &term == "xterm"
  set title
endif

" use passive FTP mode when browsing remote files
let g:netrw_ftp_cmd="ftp -p"

" rows numbering
" autocmd BufEnter *.tex setlocal number

" show a ruler with line number, % through file on status line
set ruler

" ident just 2 chars in HTML
" autocmd BufEnter *.htm? set tabstop=2 shiftwidth=2 softtabstop=2

" ident 4 chars in C
autocmd BufEnter *.[ch] set tabstop=4 shiftwidth=4 softtabstop=4 noexpandtab

" Do smart indentation depending on code syntax (e.g. change after { }, keywords etc)
set smartindent

" Show leading and trailing whitespace
"set list listchars=tab:»·,trail:·

" PHP Moodle and Mahara coding style
set tabstop=4 shiftwidth=4 softtabstop=4 expandtab

" automatically indent files
set autoindent

set backspace=indent,eol,start

" ctrl-d and ctrl-u for scrolling by one line
setlocal scroll=1

syntax on
colorscheme mudrd8mz

" highlight trailing whitespace
:highlight ExtraWhitespace ctermbg=red guibg=red
:match ExtraWhitespace /\s\+\%#\@<!$/
:au InsertEnter * match ExtraWhiteSpace /\s\+\%#\@<!$/
:au InsertLeave * match ExtraWhiteSpace /\s\+$/

" highlight do not commit mark
:highlight DoNotCommit ctermbg=red guibg=red
:match DoNotCommit /DONOTCOMMIT/

" latexSuite tips
filetype plugin on
set grepprg=grep\ -nH\ $*
filetype indent on

" Restore your cursor position in a file over several editing sessions.
set viminfo='10,\"100,:20,%,n~/.viminfo
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif
au BufEnter COMMIT_EDITMSG :normal 1G

" (), ] or }) matching
set showmatch

map <PageDown> :set scroll=0<CR>:set scroll^=2<CR>:set scroll-=1<CR><C-D>:set scroll=0<CR>
map <PageUp> :set scroll=0<CR>:set scroll^=2<CR>:set scroll-=1<CR><C-U>:set scroll=0<CR>

" F5 put a Moodle debugging msg
map <F5> oprint_object(); die(); // DONOTCOMMIT<Esc>23hi

" F8 taglist
let Tlist_GainFocus_On_ToggleOpen = 1
map <F8><Esc> :TlistToggle<CR>
nnoremap <silent> <F8> :TlistToggle<CR>

" F9 save and run make
map <F9> :w<CR>:!make<CR>

" F10 toggle the insert mode for mouse middle button clipboard paste
map <F10> :call Paste_on_off()<CR>
set pastetoggle=<F10>

let paste_mode = 0 " 0 = normal, 1 = paste

func! Paste_on_off()
        if g:paste_mode == 0
                set paste
                let g:paste_mode = 1
        else
                set nopaste
                let g:paste_mode = 0
        endif
        return
endfunc

" F12 switch encoding to latin2
map <F12> :call Switch_to_latin2()<CR>

func! Switch_to_latin2()
    e ++enc=latin2
endfunc

" Fix problem with latex-vim suite and central european diacritics
imap <S-F4>L <Plug>Tex_LeftRight
imap <S-F4>I <Plug>Tex_InsertItem

"
" Mapping for mouse wheel support - see ~/.Xdefaults
"
":map <M-Esc>[62~ <MouseDown>
":map! <M-Esc>[62~ <MouseDown>
":map <M-Esc>[63~ <MouseUp>
":map! <M-Esc>[63~ <MouseUp>
":map <M-Esc>[64~ <S-MouseDown>
":map! <M-Esc>[64~ <S-MouseDown>
":map <M-Esc>[65~ <S-MouseUp>
":map! <M-Esc>[65~ <S-MouseUp>

" <Backslash>+p is mapped to run the current buffer through a Python
" interpreter. The output appears in a new window below the current one.
" This uses the handy preview window feature of Vim. Flagging a window as a
" preview window is useful because you can use pclose! to get rid of it,
" meaning you can reuse that vim real estate over and over for commands that
" produce output, and the output has to go somewhere.
" http://strongdynamic.blogspot.com/2007/10/vim-run-current-buffer-as-python-code.html
func! DoRunPyBuffer2()
pclose! " force preview window closed
setlocal ft=python
" copy the buffer into a new window, then run that buffer through python
sil %y a | below new | sil put a | sil %!python -
" indicate the output window as the current previewwindow
setlocal previewwindow ro nomodifiable nomodified
" back into the original window
winc p
endfu
command! RunPyBuffer call DoRunPyBuffer2()
map <Leader>p :RunPyBuffer<CR>

autocmd BufWritePost */vimperator-*.tmp exe 'write ' .  fnameescape((exists('$TMPDIR') ? $TMPDIR : '/tmp') . '/vimperator.ctrl-i.' .  strftime('%Y.%m.%d.%H%M%S'))

"
" Vala - see http://live.gnome.org/Vala/Vim
"
autocmd BufRead *.vala set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
autocmd BufRead *.vapi set efm=%f:%l.%c-%[%^:]%#:\ %t%[%^:]%#:\ %m
au BufRead,BufNewFile *.vala            setfiletype vala
au BufRead,BufNewFile *.vapi            setfiletype vala
" Disable valadoc syntax highlight
"let vala_ignore_valadoc = 1

" Enable comment strings
let vala_comment_strings = 1

" Highlight space errors
let vala_space_errors = 1
" Disable trailing space errors
"let vala_no_trail_space_error = 1
" Disable space-tab-space errors
let vala_no_tab_space_error = 1

" Minimum lines used for comment syncing (default 50)
"let vala_minlines = 120

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" http://vim.wikia.com/wiki/VimTip1369
" Preserve noeol (missing trailing eol) when saving file. In order
" to do this we need to temporarily 'set binary' for the duration of
" file writing, and for DOS line endings, add the CRs manually.
" For Mac line endings, also must join everything to one line since it doesn't
" use a LF character anywhere and 'binary' writes everything as if it were Unix.

" This works because 'eol' is set properly no matter what file format is used,
" even if it is only used when 'binary' is set.

augroup automatic_noeol
au!

au BufWritePre  * call TempSetBinaryForNoeol()
au BufWritePost * call TempRestoreBinaryForNoeol()

fun! TempSetBinaryForNoeol()
  let s:save_binary = &binary
  if ! &eol && ! &binary
    setlocal binary
    if &ff == "dos" || &ff == "mac"
      undojoin | silent 1,$-1s#$#\=nr2char(13)
    endif
    if &ff == "mac"
      let s:save_eol = &eol
      undojoin | %join!
      " mac format does not use a \n anywhere, so don't add one when writing in
      " binary (uses unix format always)
      setlocal noeol
    endif
  endif
endfun

fun! TempRestoreBinaryForNoeol()
  if ! &eol && ! s:save_binary
    if &ff == "dos"
      undojoin | silent 1,$-1s/\r$/
    elseif &ff == "mac"
      undojoin | %s/\r/\r/g
      let &l:eol = s:save_eol
    endif
    setlocal nobinary
  endif
endfun

augroup END
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""