(Vim Plugin) fugitive 설치 및 팁

"vim tool 쉽게 설치하려고 번들 만드는 과정에서 코드 추가.
vundle을 설치했다면 코드가 많이 있을거다.

그중 call vundle#begin()와 call vundle#end() 사이에

Plugin 'tpope/vim-fugitive

을 추가해준다.

call vundle#begin()
Plugin 'tpope/vim-fugitive'
" 1. fugitive vim 창에서 git add, commit 같은 기능을 수행할 수 있음.
call vundle#end()            " required

그리고 새로운 vi창을 열고 vim명령모드에서 아래의 코드를 입력해준다.

:PluginInstall

그럼 fugitive가 설치된다.

간단한 테스트

:G status
:G add .
:G commit -m "hi"
:G push

위와같이 터미널에서 했던 명령들이 vim명령모드에서 가능하다.

하지만 이걸 그대로 쓰면 일일이 다 입력해야하기 때문에 귀찮다.

메크로를 설정하자.

call vundle#end()

~/.vimrc에서 위의 코드가 있었다. 해당 코드 밑에 아래의 코드를 추가하자.

아래 코드는 vim에서 메크로로 사용될 명령들이다.
나는 자주 쓰지 않는 내용들은 주석 처리해두었다. 혹시 다른기능들도 쓴다면 "을 지우고 사용하면 된다.

"nnoremap <Leader>gs :Gstatus<CR>
" fugitive git bindings , <CR> is 개행(enter)
"nnoremap <space>ga :Git add %:p<CR><CR>
nnoremap <space>ga :Git add %<TAB><Cr>
nnoremap <space>gfi :Git add %<TAB><Cr> G status<CR>
"add % 할때 %는 현재파일을 나타냄. 근데 파일에서 현재파일 여는거니까 swp파일도
"같이 있어서<TAB>을 통해 현재 파일만 선택
nnoremap <space>gs :G status<CR>
nnoremap <space>gc :G commit -m
nnoremap <space>gt :Gcommit -v -q %:p<CR>
"nnoremap <space>gd :Gdiff<CR>
"nnoremap <space>ge :Gedit<CR>
"nnoremap <space>gr :Gread<CR>
"nnoremap <space>gw :Gwrite<CR><CR>
nnoremap <space>gl :G log<CR>
"nnoremap <space>gp :Ggrep<Space>
"nnoremap <space>gm :Gmove<Space>
"nnoremap <space>gb :Git branch<Space>
"nnoremap <space>go :Git checkout<Space>
nnoremap <space>gps :Git push<CR>
"nnoremap <space>gpl :Dispatch! git pull<CR>

만약 nnoremap이 궁금하다면 여기 사이트에 잘 정리 되어있다.
http://jaeheeship.github.io/console/2013/11/15/vimrc-configuration.html

좋은 웹페이지 즐겨찾기