230 likes | 359 Vues
Dive into the essentials of Vim, the powerful text editor that enhances productivity through its modal editing system. This seminar covers everything from basic navigation, insertion, and deletion commands to advanced functionalities like searching, folding, and custom mappings. Learn how to manage files, utilize syntax highlighting, and fine-tune your Vimrc for optimal performance. Whether you’re new to Vim or looking to refine your skills, this presentation will equip you with practical knowledge to edit texts efficiently.
E N D
vim • vi : vi(sual) • vim : vi improved • vi != vim • http://www.vim.org/ • :help • vimtutor • http://kldp.org/~namsh/doc/vim/vim.html
vim 의 모드 편집모드 <Esc> iaoIAORsS : 명령모드 ex모드 <Esc> ZZ :q
이동 • h j k l : 기본 이동 • 3h : 세칸 왼쪽으로 • w b : 단어 단위 이동 • <C-f> <C-n> : 페이지 단위 이동 • gg(문서 시작) G(문서 끝) • 문장에서 : 0(가장 앞) |(중간) $(가장 뒤) • <C-g> : file status • :3 세번째줄로 가기
편집 • 삽입 : i a oI A O • 삭제 : x dX D s S • 수정 : r Rc • undo : u • redo : <C-r> (vim only) • copy : y (yank) (y를 두번 누르면 한줄) • paste : p P • block : v V <C-v> • 기타 : J .
찾기 • / ?(기본) # *(현재커서) %(괄호) n N • goto definition (current file only) • gd (local) • gD (global) see also tag • :set incsearch ( == :set is) • :nohl • :set ignorecase ( == :set ic)
바꾸기 • :#,#s/old/new/g • #는 줄번호 • :%s/old/new/g • 1,$s/old/new/g 파일 전체 • :#,#s/old/new/gc • c : 바꿀 때마다 확인
외부 실행, 파일 저장/읽기 • :!ls • :w :w! :wq (write) • :#,#w filename (범위 지정 후 저장) • :e :e! (edit) • :r (read) • :q :q!
vimrc • ./.vimrc • ~/.vimrc • /usr/share/vim/vim61/macros/vimrc • <end of vimtutor>
split • :sp <C-w>s (default : 같은 파일) • :new <C-w>n (default : 새 파일) • :vs <C-w>v (vertical split) • :20vs • :vnew • <C-w> hjkl • <C-w> +-=<>
modline 파일 앞쪽이나 뒤쪽에 vim:tw=78:ts=8:ft=help:norl: 처럼 집어넣으면 자동으로 set • :help modline
mark • ma • `a 또는 ‘a • a에서 z까지 사용 가능 • A에서 Z는 다른 파일에도 적용 • :help mark
C-indenting • set autoindent (set ai) • set cindent (set ci) • set smartindent (set si) • :help C-indenting • 시스템 vimrc 에 기본적으로 되어있음 • <참고> 붙여넣기 할 때 • :set paste • :set nopaste
tabstop • tabstop (‘\t’를 몇칸으로 할지) • shiftwidth (Tab 키를 누를 때 몇 칸 이동) • softtabstop (tab과 space를 알아서) • 일반적인 Unix programming • :set ts=8 sw=4 sts=4 • visual C 세팅 • :set ts=4 • expandtab : tab을 space로 바꿔서 넣음
fold-commands • zf (fold 하기) • zd (fold 없애기) • zo (fold 열기) • zc (fold 닫기) • zm (모든 fold 닫기)
fold-methods • set fdm=marker • int func() • { /*{{{*/ • } /*}}}*/ • set fdm=indent • set fdm=manual • .vimrc 에 • au BufWinLeave *.c mkview • au BufWinEnter *.c silent loadview
tag • 변수, 함수, define 의 원형 찾아가기 • shell에서 ctags –R * (ctags 설치 후) • .vimrc에서 set tags=./tags,../tags,../include/tags,inclue/tags,tags (상황에 맞게 추가설정 가능) • <C-]> 이동 g] • <C-t> 돌아오기 • :tag function function으로 가기 see also 찾기
quickfix • :make • 에러나면 에러난 곳으로 이동 • :cl (list all error) • :cn (next error) • :copen (error window open) • :grep
ftp • vim ftp://43.76.62.76/1.txt • rcp, scp 가능
hex • ga • :set display=uhex • vim –b 또는 set bin • :!%xxd • :!%xxd –r • 저장은 약간 번거롭다 • :help hex 참고
mapping • map <F7> :make<CR> • map <F5> :make run<CR> • map <F2> ^Ww (^W는 <C-v><C-w>로 입력) • map <F5> :20vs . • map <F6> v%zf
encoding 터미널의 폰트 (굴림, MSGothic) termencoding (tenc) encoding (enc) encoding 종류 : sjis, euc-kr, euc-jp, utf-8
기타 • vim에서 삑삑하는 소리 없애기 • :set vb t_vb= • 디렉토리를 열 수도 있다 • o, O로 디렉토리 안의 파일을 연다 • :syntax on • :set nobackup • :set number • <C-a> 수++ <C-x> 수--