vim

Younghwan Cha·2022년 12월 5일
0

linux

목록 보기
2/24
post-thumbnail

VIM?


vim 은 Bram Moolenaar 가 만든 vi 호환 텍스트 편집기이다.
vim 은 마우스를 사용하지 않고 텍스트 편집을 할 수 있고 다양한 기능과 플러그인들이 있기 때문에 많은 사람들이 vim 을 사용하고 있다.

vim 을 잘 사용 할 수록 업무 효율성이 높아지기 때문에 다양한 기능과 plugin을
숙지하는 것은 큰 도움이 될 수 있다.

plugin

시간 날 때마다 plugin을 찾아보고 적용해보도록 하자.

플러그인을 설치하는 방법은 크게 두가지가 있다.
1. 수동으로 plugin 을 clone 받아서 적용
2. vim Vundle 을 이용해 plugin을 clone 받아 적용

Vundle 을 통해서 plugin을 추가해보자.
아래 코드를 통해서 Vundle 을 다운받을 수 있다.

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

이후 ~/.vimrc 에 하단 코드를 추가해준다.

"vim tool 쉽게 설치하려고 번들 만드는 과정에서 코드 추가.
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()

" 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 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}

" 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

이후 추가하려는 vim plugin 을
call vundle#begin()call vundle#end() 사이에 넣어주고
:PluginInstall을 입력하면 해당 plugin 을 사용 할 수 있다.

https://xogk39.medium.com/vim-plugin-%EC%A0%95%EB%A6%AC-f1e2b6b97b4d

command


copy

y : vim에서 복사는 일반모드에서 y 또는 yy 명령을 사용하며, y 는 '뽑아내다' 라는 뜻을 가진 yank 에서 유래된 명령어다.

paste

p: 복사 또는 잘라내기로 레지스터에 저장한 내용을 일반모드에서 p 키를 이용해서 붙여넣을 수 있다.

delete

x: 커서에 존재하는 문자열 삭제
dd: 현재 행 삭제

undo & redo

u: 바로 직전 기능 취소 (undo)
Ctrl + R: undo 명령어 되돌리기

주석 처리


v 를 누르면 visual 모드로 전환된다

hjkl 을 통해서 블록을 설정한 이후에

: 을 누르면 '<', > 이 나타난다.

이후에,

norm i<원하는 문자>

ex) norm i# 

제거를 원한다면,

앞쪽 1개 문자 삭제
norm 1x

앞쪽 2개 문자 삭제
norm 2x

show number


# show line number
:set number 

# remove line number
:set number!
profile
개발 기록

0개의 댓글