Jan 6, 2017

.vimrc 설정방법 공유


vim, vimrc 폴더 다운로드 링크



.vimrc 파일 내용


"===== Vundle =====
set nocompatible              " be iMproved, required
filetype off                  " required
" 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.
" 여기에  원하는 플러그인 삽입
" NERD Tree
Plugin 'scrooloose/nerdtree'
" NERD Tree Git Plugin
Plugin 'Xuyuanp/nerdtree-git-plugin'
" 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
"
"

"===== Basic Variables =====
"syntax on                                      " Enables Vim to show parts
                                                " of the text in another font or color
colorscheme vibrantink
"set lines=50 columns=120                       " 창 크기 설정
set fencs=utf-8,euc-kr,cp949,cp932,big5,latin1,urs-2le,shift-jis,euc-jp
"set fileencoding=utf-8
set ls=2                                        " 작업표시줄 항상 표시
set nu                                          " display line numbers on the left
set ts=4                                        " tab space
set sw=4                                        " Shift Width
set ruler                                       " display the cursor position on the last line of the screen
set nobackup                                    " no backup
set backspace=eol,start,indent                  " 백스페이스 사용하면 이전줄과 연결됨
set autoindent                                  " automatically indent
set cindent                                     " automatically indent in C files.
set smartindent                                 " smart indent
set ic                                          " 검색 시 대소문자 구별 안함
set nows                                        " 검색 시 파일 끝에서 처음으로 되돌리기 안함
set hls                                         " 검색어 강조
"===== 버퍼간 파일 이동 =====
map ,1 :b!1<cr>
map ,2 :b!2<cr>
map ,3 :b!3<cr>
map ,4 :b!4<cr>
map ,5 :b!5<cr>
map ,6 :b!6<cr>
map ,7 :b!7<cr>
map ,8 :b!8<cr>
map ,9 :b!9<cr>
map ,0 :b!0<cr>
map ,w :bw<cr>                          " remove current bufferfile

"======== KEY MAPPING ========
map <f1> K
map <f2> <c-w>w
map <f3> gg=G
"map <f4> :cn<cr>                        " :cw -&gt; window showing the locaion list for the current window.
"map <f5> :!./%&lt;
"map <f6> :!clear<cr>:w<cr>:make<cr>
"map <f7> :!clear<cr>:w<cr>:!gcc -W -Wall % -o %&lt;<cr>
"au BufWinEnter *.java
"\ map <f5> :!java %&lt;
"au BufWinEnter *.java,*.cpp,*.c
"\ map <f7> I//<esc>
"au BufWinEnter *.java,*.cpp,*.c
"\ map <f8> ^xx
"map <f9> :!ctags -R<cr>
"au BufWinEnter *.cpp
"\ map <f9> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<cr>
"map <f10> <c->                         " 태그 검색
"map <f11> <c-t>                         " 태그 복귀
map <f12>1 :NERDTree<cr>
"map <f12>2 :TlistToggle<cr>
map <f12>3 gg=G
map ,m :new Makefile<cr>:/PROGS<cr>ww
map <pageup> <c-b>
map <pagedown> <c-f>
"저장
"map <c-s> :w<cr>
"복사
"map <c-c> :'a,'b w! ~/tmp/tmp<cr>
"붙여넣기
"map <c-p> :r ~/tmp/tmp<cr>

NERD Tree 개발버전, NERD Tree git plugin 을 Vundle로 설치


NERD Tree 란 아래 그림과 같이 vim에서 파일시스템을 탐색하고 파일을 열 수 있도록 도와주는 플러그인이다.
http://www.vim.org/scripts/script.php?script_id=1658


https://www.flickr.com/photos/30496122@N07/2862367534/sizes/o/


nerd tree git plugin은 vim 에서 git 저장소의 상태확인을 위해 쓴다.
https://camo.githubusercontent.com/3fe0388df11cb787f36e1fa108398fd3f757eef4/687474703a2f2f692e696d6775722e636f6d2f6a534377476a552e6769663f31
https://github.com/Xuyuanp/nerdtree-git-plugin



1. 설치방법

vimrc를 열어 vundle 플러그인 삽입란에 아래 2라인을 추가한다.

Plugin 'scrooloose/nerdtree'
Plugin 'Xuyuanp/nerdtree-git-plugin'


<플러그인이 추가된 모습>


저장 후 vim 에서 :PluginInstall 입력

설치완료.

.vim .vimrc 작업1 - Vundle 설치

Vundle 은 Vim 플러그인 관리 도구이다.
https://github.com/VundleVim/Vundle.vim

html 이라는 플러그인을 설치할려고 할때
오리지날 vim 플러그인 시스템은

vim/
    syntax/
        html.vim
    indent/
        html.vim

이런식으로 저장되는데

Vundle은

vim/bundle/
    html/
        syntax/
            html.vim
        indent/
            html.vim

이렇게 저장된다.

Vundle의 장점은 html 플러그인을 bundle로서 관리하여 해당 플러그인의 모든 파일을 알맞은 디렉토리에 저장하고 관리하기 편하게 도와준다.


설치하기 앞서 git 이 설치되어있어야한다. git은 sudo apt-get install git 로 설치하면 된다.

1. Vundle Clone

jkpark@cactus:~$ git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

2. vimrc 기본 설정

아래 내용을 .vimrc 파일의 제일 윗줄에 추가한다.

* 설치와 테스트를 위해 NERD Tree 플러그인을 설치할 것이다.
"===== Vundle =====
set nocompatible              " be iMproved, required
filetype off                  " required
" 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.
" 여기에  원하는 플러그인 삽입


" 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 in
"
" 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

3. 플러그인 검색 및 설치

플러그인 검색 방법은 vimrc파일을 열어 :BundleSearch 를 입력하면 플러그인 리스트가 출력된다.

원하는 플러그인은 http://vim-scripts.org/vim/scripts.html 에서 찾을 수 있다.
원하는 플러그인을 찾은다음, 해당 이름을 검색하고
Shift+V 라인 선택
Y키로 복사
Ctrl+W ->w 로 창 이동
P로 붙여넣기
하면 아래와 같이 붙여넣기가 된다.



4. 인스톨

vim 을 열고 :PluginInstall 을 입력한 후 엔터

5. 확인

.vim/bundle 에서 설치된 플러그인이 존재하는지 확인한다.
jkpark@cactus:~/.vim/bundle$ ls -al
합계 20
drwxrwxr-x 5 jkpark jkpark 4096  1월  6 14:41 .
drwxrwxr-x 3 jkpark jkpark 4096  1월  6 14:27 ..
drwxrwxr-x 8 jkpark jkpark 4096  1월  6 14:27 Vundle.vim
drwxrwxr-x 9 jkpark jkpark 4096  1월  6 14:41 nerdtree
jkpark@cactus:~/.vim/bundle$



또한 vim 에서 :NERDTree 를 입력후 엔터치면 아래 그림과 같이 NERDTree가 실행된다.