메뉴 건너뛰기

Dev tips

Linux Server .vimrc 현재 설정

taknim 2016.02.22 18:08 조회 수 : 1598 추천:153

set encoding=utf-8

" set ai     " auto indent
set notitle
set bg=light
set ts=2
set sts=2
set sw=2
" set et   " use spaces instead of tab
set sm
set cinoptions={s,>2s,n-s,^-s
set ruler
set report=0
set hlsearch

set nocompatible  " Use Vim defaults (much better!)
set bs=2    " allow backspacing over everything in insert mode

set ls=2

" set t_kb=^H
" set t_kD=^?

autocmd BufNewfile,BufRead,BufEnter *.tpl         set filetype=php
autocmd BufNewfile,BufRead,BufEnter *.php         set filetype=php
autocmd BufNewfile,BufRead,BufEnter .bash_profile set filetype=sh
autocmd BufNewfile,BufRead,BufEnter .bashrc       set filetype=sh
autocmd BufNewfile,BufRead,BufEnter *.js          set filetype=javascript
autocmd BufNewfile,BufRead,BufEnter *.c           set filetype=c
autocmd BufNewfile,BufRead,BufEnter *.ec          set filetype=c
autocmd BufNewfile,BufRead,BufEnter *.h           set filetype=c
autocmd BufNewfile,BufRead,BufEnter *.cpp         set filetype=cpp
autocmd BufNewfile,BufRead,BufEnter *.cxx         set filetype=cpp
autocmd BufNewfile,BufRead,BufEnter *.c++         set filetype=cpp
autocmd BufNewfile,BufRead,BufEnter *.sql         set filetype=sql
autocmd BufNewfile,BufRead,BufEnter *.sh          set filetype=sh
autocmd BufNewfile,BufRead,BufEnter *.pl          set filetype=perl
autocmd BufNewfile,BufRead,BufEnter *.ps          set filetype=python
autocmd BufNewfile,BufRead,BufEnter *.java        set filetype=java
autocmd BufNewfile,BufRead,BufEnter *.html        set filetype=html
autocmd BufNewfile,BufRead,BufEnter *.vim         set filetype=vim
autocmd BufNewfile,BufRead,BufEnter .vimrc        set filetype=vim

syntax on

filetype plugin on
filetype indent on

if has("folding")
  set fdm=marker
endif

set tags=~/work/git/tags
set tagbsearch

set wmnu

" set csprg=/usr/local/bin/cscope
" set csto=0
" set cst
" set nocsverb
" cs add ~/work/svn/cscope.out
" set csverb

" CI 사용을 위한 단축키 설정

if version >= 500

  func! Vview() " views
    let st = expand("<cword>")
    let pa = expand("%:h")

    let ln = getline(line("."))
    let curpos = col(".")
    let p2 = strridx(ln, "/", curpos)

    if p2 > -1
      let p1 = strridx(ln, "\'", p2)
      if p1 == -1
        let p1 = strridx(ln, "\"", p2)
      endif
      let st = strpart(ln, p1 + 1, p2 - p1).st
    endif

    if stridx(expand("%:h"), "views") == -1
      let pp = "../views/"
    else
      let pp = "../../views/"
    endif

    exe "sp ".pa."/".pp.st.".php"
  endfunc

  func! Vwascont() " was controllers
    let st = toupper(strpart(expand("<cword>"), 0, 1)).strpart(expand("<cword>"), 1)
    let pa = "/var/www/was/application/controllers"
    exe "sp "pa."/".st.".php"
  endfunc

  func! Vwasmodel() " was models
    let st = toupper(strpart(expand("<cword>"), 0, 1)).strpart(expand("<cword>"), 1)
    let pa = "/var/www/was/application/models"
    if !filereadable(pa."/".st.".php")
      let st =toupper(strpart(expand("<cword>"), 0, 1)).strpart(expand("<cword>"), 1)."_m"
      if !filereadable(pa."/".st.".php")
        let st =toupper(strpart(expand("<cword>"), 0, 1)).strpart(expand("<cword>"), 1)."_model"
      endif
    endif
    exe "sp ".pa."/".st.".php"
  endfunc

  nmap ,, :call Vview()<cr>
  nmap ,. :call Vwascont()<cr>
  nmap ,m :call Vwasmodel()<cr>

endif
 

 

[참고]

http://vimdoc.sourceforge.net/htmldoc/eval.html#getcmdpos()