IT Repository

vim 설정 (with vim-plug) 본문

환경설정

vim 설정 (with vim-plug)

IT찬니 2022. 1. 23. 20:16
  1. vim-plug 설치 (https://github.com/junegunn/vim-plug)
    curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    	https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim​
     
  2. .vimrc 편집
    call plug#begin('~/.vim/plugged')
    
    " Add plugins, which you want to install
    " Find plugins in https://vimawesome.com
    
    if has('nvim')
      Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
    else
      Plug 'Shougo/deoplete.nvim'
      Plug 'roxma/nvim-yarp'
      Plug 'roxma/vim-hug-neovim-rpc'
    endif
    
    Plug 'gmarik/Vundle.vim'
    Plug 'nanotech/jellybeans.vim'
    Plug 'majutsushi/tagbar'
    Plug 'scrooloose/nerdtree'
    Plug 'nathanaelkane/vim-indent-guides'
    Plug 'airblade/vim-gitgutter' " vim with git status(added, modified, and removed lines)
    Plug 'tpope/vim-fugitive' " vim with git command(e.g., Gdiff)
    Plug 'vim-airline/vim-airline' " vim status bar
    Plug 'vim-airline/vim-airline-themes'
    Plug 'blueyed/vim-diminactive'
    Plug 'inkarkat/vim-ReplaceWithRegister'
    Plug 'dbakker/vim-paragraph-motion'
    "Plug 'mg979/vim-visual-multi', {'branch': 'master'}
    Plug 'terryma/vim-multiple-cursors'
    Plug 'terryma/vim-smooth-scroll'
    Plug 'terryma/vim-expand-region'
    
    call plug#end()
    
    "...
  3. plugin 설치 (USE THIS INSIDE VIM)
    # 1. Usage: Common
    :PlugInstall # 설치
    :PlugUpdate # 플러그인 업데이트
    :PlugClean # 삭제
    :PlugStatus # 상태
    :PlugDiff # 플러그인 변경 이력
    :PlugUpgrade # vim-plug 업데이트
    
    # 2. Usage: Snapshot
    :PlugSnapshot <SNAPSHOT_PATH> # 플러그인 스냅샷 세이브
    vim -S <SNAPSHOT_PATH> # 플러그인 스냅샷 로드
  4. Example: .vimrc 
    set shell=/bin/bash
    
    " set rtp+=~/.vim/bundle/Vundle.vim
    
    " call vundle#begin()
    call plug#begin('~/.vim/plugged')
    
    Plug 'gmarik/Vundle.vim'
    Plug 'nanotech/jellybeans.vim'
    Plug 'majutsushi/tagbar'
    Plug 'scrooloose/nerdtree'
    Plug 'nathanaelkane/vim-indent-guides'
    Plug 'airblade/vim-gitgutter' " vim with git status(added, modified, and removed lines)
    Plug 'tpope/vim-fugitive' " vim with git command(e.g., Gdiff)
    Plug 'vim-airline/vim-airline' " vim status bar
    Plug 'vim-airline/vim-airline-themes'
    Plug 'blueyed/vim-diminactive'
    Plug 'inkarkat/vim-ReplaceWithRegister'
    Plug 'dbakker/vim-paragraph-motion'
    " Plug 'mg979/vim-visual-multi', {'branch': 'master'}
    Plug 'terryma/vim-multiple-cursors'
    Plug 'terryma/vim-smooth-scroll'
    Plug 'terryma/vim-expand-region'
    
    " call vundle#end()
    call plug#end()
    
    " set values
    set nocompatible
    set cursorline " show line indicator
    set number " show row number
    set hlsearch " enable highlight for search result
    set visualbell " enable visual notification, instead of tick sound
    set autoindent " auto indent fitting previous indent level
    set smartindent " smart indent
    set t_Co=256 " term color is 256
    set tabstop=4 " space size for tab key
    set shiftwidth=4 " auto indent length
    set clipboard=unnamed " share clipboard with host os
    
    " other config
    filetype plugin on
    filetype indent on " syntax highlight for filetype
    syntax on " enable syntax highlight
    highlight Comment term=bold cterm=bold ctermfg=4
    
    " support % to html/css
    runtime macros/matchit.vim
    
    " for jellybeans
    colorscheme jellybeans
    
    " for taglist
    nmap <F8> :Tagbar<CR>
    
    " for filelist
    nmap <F7> :NERDTreeToggle<CR>
    
    " for indent guide
    let g:indentguides_spacechar = '┆'
    let g:indentguides_tabchar = '|'
    let g:indent_guides_enable_on_vim_startup = 1
    let g:indent_guides_start_level=2
    let g:indent_guides_guide_size=1
    
    " for vim-airline
    let g:airline#extensions#tabline#enabled = 1 " turn on buffer list
    let g:airline_theme='hybrid'
    set laststatus=2 " turn on bottom bar
    nnoremap <leader>q :bp<CR>
    nnoremap <leader>w :bn<CR>
    
    " for blueyed/vim-diminactive
    let g:diminactive_enable_focus = 1
    
    " for vim-expand-region
    let g:expand_region_use_select_mode = 1
    
    " for smooth-scroll (disabled for IDE)
    "noremap <silent> <C-B> :call smooth_scroll#up(&scroll*2, 10, 5)<CR>
    "noremap <silent> <C-F> :call smooth_scroll#down(&scroll*2, 10, 5)<CR>
    "noremap <silent> <C-U> :call smooth_scroll#up(&scroll, 10, 3)<CR>
    "noremap <silent> <C-D> :call smooth_scroll#down(&scroll, 10, 3)<CR>
    
    " mapleader
    let mapleader = " "
    
    " key map: move
    nnoremap <Tab> >>_
    nnoremap <S-Tab> <<_
    nnoremap <S-h> ^
    nnoremap <S-l> $
    "vnoremap <Tab> >gv
    "vnoremap <S-Tab> <gv
    
    " key map: edit
    inoremap jj <ESC>
    
    " key map: etc
    noremap <leader>z :set paste!<CR> " paste mode ON/OFF
    noremap <leader>/ :nohlsearch<CR>​

'환경설정' 카테고리의 다른 글

Jupyter Remote Access  (0) 2022.01.30
NVM 설치 및 세팅  (0) 2022.01.23
Jenv 설치 및 세팅  (0) 2022.01.23
Pyenv 설치 및 세팅  (0) 2022.01.23
Poetry 설치 및 세팅  (0) 2022.01.23
Comments