내밥줄/프로그래밍

vim 설정

jjoell 2017. 4. 17. 07:05

set nocompatible " VI 오리지널과 호환하는 모드를 사용하지 않음(VIM확장)

set number " 라인번호를 붙임

set backspace=indent,eol,start " BS로 라인끝과 처음 자동들여쓰기한 부분을 지날수 있음

"set visualbell " Alert 음을 화면 깜박임으로 바꿔보여주기

set laststatus=5 " 최종상태 2개 기억하기

set statusline=%h%F%m%r%=[%l:%c(%p%%)] " 상태표시줄 포맷팅

set hlsearch  " / ? 명령 등으로 찾은 문자열을 하일라이트 해준다.

set ignorecase

syntax on " 적절히 Syntax에 따라 하일라이팅 해주기

colorscheme delek

filetype indent on " 파일 종류에 따라 구문강조


set nocindent

set autoindent " 자동 들여쓰기

set smartindent


"cscope 설정

set csprg=/usr/bin/cscope

set csto=0

set cst

set nocsverb

"set paste

set ruler

set t_ti= t_te= " 종료시 화면이 남도록...

set showmatch " matching 되는 괄호 표시

set diffopt+=iwhite

set softtabstop=4                              " TAB키를 눌렀을때 몇 칸을 이동?

set tabstop=4                                  " 하나의 TAB을 몇 칸으로 인식?

set shiftwidth=4                               " <<, >>을 눌렀을 때 몇 칸을 이동?

set expandtab                                  " TAB을 space로 인식

"set noexpandtab                                " TAB을 TAB으로 인식


" Clever Tab features -------------------------------------------------------

function! CleverTab()

    if strpart( getline('.'), 0, col('.')-1 ) =~ '^\s*$'

        return "\<Tab>"

    else

        return "\<C-N>"

endfunction

inoremap <Tab> <C-R>=CleverTab()<CR>


"if filereadable("./cscope.out")

"    cs add cscope.out

"elseif filereadable("~/cscope.out")

"    cs add ~/cscope.out

"else

"    cs add /usr/src/kernels/2.6.34.9-69.fc13.i686/cscope.out

"endif

set csverb

"set diffexpr=MyDiffJun()

"function MyDiffJun()

"   let opt = ""

"   if &diffopt =~ "icase"

"     let opt = opt . "-i "

"   endif

"   if &diffopt =~ "iwhite"

"     let opt = opt . "-b "

"   endif

"   silent execute "!diff -a --binary " . opt . v:fname_in . " " . v:fname_new .

"    \  " > " . v:fname_out

"endfunction


set nocompatible              " be iMproved, required

filetype off                  " required

fun! <SID>StripTrailingWhitespaces()

    let l = line(".")

    let c = col(".")

    %s/\s\+$//e

    call cursor(l, c)

endfun


autocmd FileType c,cpp,java,php,ruby,python autocmd BufWritePre <buffer> :call <SID>StripTrailingWhitespaces()


" set the runtime path to include Vundle and initialize

set rtp+=~/.vim/bundle/Vundle.vim

call vundle#begin()

" alternatively, pass a path where Vundle should install plugins

"call vundle#begin('~/some/path/here')


" let Vundle manage Vundle, required

Plugin 'VundleVim/Vundle.vim'


" The following are examples of different formats supported.

" Keep Plugin commands between vundle#begin/end.

" plugin on GitHub repo

Plugin 'Valloric/YouCompleteMe'


" All of your Plugins must be added before the following line

call vundle#end()            " required

filetype plugin indent on    " required

" To ignore plugin indent changes, instead use:

"filetype plugin on

"

" Brief help

" :PluginList       - lists configured plugins

" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate

" :PluginSearch foo - searches for foo; append `!` to refresh local cache

" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal

"

" see :h vundle for more details or wiki for FAQ

" Put your non-Plugin stuff after this line


let g:ycm_global_ycm_extra_conf = '~/.vim/.ycm_extra_conf.py'

let g:ycm_confirm_extra_conf = 0

"let g:ycm_key_list_select_completion = ['', '']

"let g:ycm_key_list_previous_completion = ['', '']

let g:ycm_autoclose_preview_window_after_completion = 1

let g:ycm_warning_symbol = '>*'


let g:ycm_min_num_of_chars_for_completion = 1    " 기본값은 2입니다. 문자가 1개 입력되면 그 때부터 자동완성을 시작합니다. 쓰지 않을

려면 99같은 큰 값을 넣어줍니다.

let g:ycm_auto_trigger = 0    " 기본값은 1입니다. '.'이나 '->'을 받으면 자동으로 목록들을 출력해주죠.

let g:ycm_collect_identifiers_from_tags_files = 1    " tags 파일을 사용합니다. 성능상 이익이 있는걸로 알고 있습니다.

let g:ycm_filetype_whitelist = { '*': 1 }    " 화이트 리스트를 설정합니다.

let g:ycm_filetype_blacklist = {

      \ 'tagbar' : 1,

      \ 'qf' : 1,

      \ 'notes' : 1,

      \}    " 블랙 리스트를 설정합니다.


"To avoid conflict snippets

let g:ycm_key_list_select_completion = ['<C-j>', '<Down>']

let g:ycm_key_list_previous_completion = ['<C-k>', '<Up>']

let g:ycm_python_binary_path = '/usr/bin/python'


"nnoremap g :YcmCompleter GoTo

"nnoremap gg :YcmCompleter GoToImprecise

"nnoremap d :YcmCompleter GoToDeclaration

"nnoremap t :YcmCompleter GetType

"nnoremap p :YcmCompleter GetParent

nnoremap <leader>g :YcmCompleter GoTo<CR>

nnoremap <leader>gg :YcmCompleter GoToImprecise<CR>

nnoremap <leader>d :YcmCompleter GoToDeclaration<CR>

nnoremap <leader>t :YcmCompleter GetType<CR>

nnoremap <leader>p :YcmCompleter GetParent<CR>