페이지

2012년 1월 18일 수요일

Vim 설치, 설정

VIM 을 위한 앱, 플러그인, 설정들

설정파일 ~/.vimrc
" Environment {
    " Basics {
        set nocompatible   " must be first line
        "set background=dark     " Assume a dark background
    " }
    "
    " Windows Compatible {
        " On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization
        " across (heterogeneous) systems easier. 
        if has('win32') || has('win64')
            set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
        endif
    " }
" }

" General {
    if !has('win32') && !has('win64')
        set term=$TERM       " Make arrow and other keys work
    endif
    filetype plugin indent on   " Automatically detect file types.

    au BufRead,BufNewFile *.mm set filetype=objc

    syntax on      " syntax highlighting
    set mouse=a     " automatically enable mouse usage
    set autochdir     " always switch to the current file directory.. Messes with some plugins, best left commented out
    " not every vim is compiled with this, use the following line instead
    " If you use command-t plugin, it conflicts with this, comment it out.
        "autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif
    scriptencoding utf-8

    " set autowrite                  " automatically write a file when leaving a modified buffer
    set shortmess+=filmnrxoOtT      " abbrev. of messages (avoids 'hit enter')
    set viewoptions=folds,options,cursor,unix,slash " better unix / windows compatibility
    set virtualedit=onemore      " allow for cursor beyond last character
    set history=1000      " Store a ton of history (default is 20)
    "set spell              " spell checking on
    
    nnoremap <C-e> 3<C-e>
    nnoremap <C-y> 3<C-y>

    let g:netrw_browse_split=3   "new tab
    let g:netrw_liststyle=3      "tree style listing

    " Setting up the directories {
        "set backup       " backups are nice ...
        "set undofile     " so is persistent undo ...
        "set undolevels=1000 "maximum number of changes that can be undone
        "set undoreload=10000 "maximum number lines to save for undo on a buffer reload
           " Moved to function at bottom of the file
        "set backupdir=$HOME/.vimbackup//  " but not when they clog .
        "set directory=$HOME/.vimswap//  " Same for swap files
        "set viewdir=$HOME/.vimviews//  " same for view files
     
        "" Creating directories if they don't exist
        "silent execute '!mkdir -p $HVOME/.vimbackup'
        "silent execute '!mkdir -p $HOME/.vimswap'
        "silent execute '!mkdir -p $HOME/.vimviews'
        "au BufWinLeave * silent! mkview  "make vim save view (state) (folds, cursor, etc)
        "au BufWinEnter * silent! loadview "make vim load view (state) (folds, cursor, etc)
    " }
" }


" Vim UI {
    color jellybeans "desert
    set t_Co=256
    set tabpagemax=15
    set showmode
    set cursorline

    if has('cmdline_info')
        set ruler                   " show the ruler
        set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " a ruler on steroids
        set showcmd                 " show partial commands in status line and
            " selected characters/lines in visual mode
    endif

    if has('statusline')
        set laststatus=2

        " Broken down into easily includeable segments
        set statusline=%<%f\    " Filename
        set statusline+=%w%h%m%r " Options
        "set statusline+=%{fugitive#statusline()} "  Git Hotness
        set statusline+=\ [%{&ff}/%Y]            " filetype
        set statusline+=\ [%{getcwd()}]          " current dir
        set statusline+=\ [A=\%03.3b/H=\%02.2B] " ASCII / Hexadecimal value of char
        set statusline+=%=%-14.(%l,%c%V%)\ %p%%  " Right aligned file nav info
    endif

    set backspace=indent,eol,start " backspace for dummys
    set linespace=0    " No extra spaces between rows
    set nu      " Line numbers on
    set showmatch    " show matching brackets/parenthesis
    set incsearch     " find as you type search
    set hlsearch     " highlight search terms
    set winminheight=0    " windows can be 0 line high 
    set ignorecase     " case insensitive search
    set smartcase     " case sensitive when uc present
    set wildmenu     " show list instead of just completing
    set wildmode=list:longest,full " command <Tab> completion, list matches, then longest common part, then all.
    set whichwrap=b,s,h,l,<,>,[,] " backspace and cursor keys wrap to
    set scrolljump=5     " lines to scroll when cursor leaves screen
    set scrolloff=3     " minimum lines to keep above and below cursor
    set foldenable      " auto fold code
    set gdefault     " the /g flag on :s substitutions by default
    set list
    "set listchars=tab:~\ ,trail:.,extends:#,nbsp:.,eol:$ " Highlight problematic whitespace
    set listchars=trail:⋅,nbsp:⋅,tab:▷⋅

" }

" Formatting {
    set wrap                      " wrap long lines
    set autoindent                  " indent at the same level of the previous line
    set shiftwidth=4                " use indents of 4 spaces
    "set expandtab            " tabs are spaces, not tabs
    set tabstop=4      " an indentation every four columns
    set softtabstop=4     " let backspace delete indent
    set matchpairs+=<:>             " match, to be used with % 
    set pastetoggle=<F12>           " pastetoggle (sane indentation on pastes)
    "set comments=sl:/*,mb:*,elx:*/  " auto format comment blocks
    " Remove trailing whitespaces and ^M chars
    autocmd FileType c,cpp,java,php,js,python,twig,xml,yml autocmd BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
" }

댓글 없음:

댓글 쓰기