set langmenu=none
language en
colors torte
syn on
set nobackup
set ic " do incremental search
set is
set hls
set ai
set ruler " show status
set cindent
set sw=4
set ts=4
set bs=2 " allow backspacing over everything in insert mode
set nowrap
set showmatch " show matched brace
filetype plugin indent on
" CTRL-X and SHIFT-Del are Cut
vnoremap <C-X> "+x
vnoremap <S-Del> "+x
" CTRL-C and CTRL-Insert are Copy
vnoremap <C-C> "+y
vnoremap <C-Insert> "+y
" CTRL-V and SHIFT-Insert are Paste
map <C-V> "+gP
map <S-Insert> "+gP
cmap <C-V> <C-R>+
cmap <S-Insert> <C-R>+
" Pasting blockwise and linewise selections is not possible in Insert and
" Visual mode without the +virtualedit feature. They are pasted as if they
" were characterwise instead.
" Uses the paste.vim autoload script.
exe 'inoremap <script> <C-V>' paste#paste_cmd['i']
exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']
imap <S-Insert> <C-V>
vmap <S-Insert> <C-V>
" Use CTRL-Q to do what CTRL-V used to do
noremap <C-Q> <C-V>
" Use CTRL-S for saving, also in Insert mode
noremap <C-S> :update<CR>
vnoremap <C-S> <C-C>:update<CR>
inoremap <C-S> <C-O>:update<CR>
" For CTRL-V to work autoselect must be off.
" On Unix we have two selections, autoselect can be used.
if !has("unix")
set guioptions-=a
endif
" CTRL-Z is Undo; not in cmdline though
noremap <C-Z> u
inoremap <C-Z> <C-O>u
" CTRL-Y is Redo (although not repeat); not in cmdline though
noremap <C-Y> <C-R>
inoremap <C-Y> <C-O><C-R>
" Alt-Space is System menu
if has("gui")
noremap <M-Space> :simalt ~<CR>
inoremap <M-Space> <C-O>:simalt ~<CR>
cnoremap <M-Space> <C-C>:simalt ~<CR>
endif
" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG
" CTRL-Tab is Next window
noremap <C-Tab> <C-W>w
inoremap <C-Tab> <C-O><C-W>w
cnoremap <C-Tab> <C-C><C-W>w
onoremap <C-Tab> <C-C><C-W>w
" CTRL-F4 is Close window
noremap <C-F4> <C-W>c
inoremap <C-F4> <C-O><C-W>c
cnoremap <C-F4> <C-C><C-W>c
onoremap <C-F4> <C-C><C-W>c
if has("multi_byte")
set encoding=utf-8
else
echoerr "Sorry......"
endif
tabn[ext] n : n 번째 탭으로 이동 tabne[w] : 새 탭 생성 tabe[dit] name : 새 탭으로 편집
| 단어별 왼쪽이동 | b, #b | 4b 를 치면 4단어 왼쪽으로 이동 |
| 단어별 오른쪽이동 | w, #w | |
| 현재 단어의 끝으로 이동 | e | |
| 그 줄에서 빠른 찾기 | f#, #2f# | fi 를 치면 그줄 오른쪽에서 가장 가까운 i 로 이동, 2fi 를 치면 두번째 |
| 파일의 끝으로 이동 | Shift+G | |
| 특정 라인으로 이동 | #G | 10G : 10번째 줄로 이동 |
| Ctrl + u | 반페이지 위로 | |
| Ctrl + d | 반페이지 밑으로 |
| H | 화면의 젤 처음 라인으로 |
| M | 화면의 가운데 라인으로 |
| L | 화면의 마지막 라인으로 |
| Ctrl+g | 현재 라인의 정보 |
| '. | 마지막으로 수정한 라인 |
| v | 블럭 시작 | |
| V | 줄단위 블럭 시작 | |
| Ctrl+v | Vertical 선택 | Ctrl+v 후 에 Shift + i 를 누르고 // 를 누르고 ESC 2번 누르면 선택 부분 주석처리 |
| a마크하기 | ma |
| b마크하기 | mb |
| ... | ... |
| a마크로이동 | `a |
| b마크로이동 | `b |
| ... | ... |
^Load.*$\n : 앞에 Load 로 시작하고 아무 문자나 계속 오다가 마지막에 end-of-line 이 오는 것을 찾는다. [[:digit:]] : 숫자를 찾는다.
| setting find hilight | :set hlsearach , :set nohlsearch, current off : nohlsearch |
| setting incremental search | :set incsearch |
| 대소문자 구분끄기 | :set ic |
| 대소문자 구분켜기 | :set noic |
| 현재 단어를 아래로 찾기 | (단어위에서)* |
| 현재 단어를 위로 찾기 | (단어위에서)# |
:%s/old/new/g
| [c | 이전 diff 위치 |
| ]c | 다음 diff 위치 |
| diffg | 다른창에서 가져온다(get) |
| diffp | 다른창으로 복사한다(put) |
| vert diffsplit newfilename | 간단하게 비교창 띄우기 |
| zo | Folding Open |
| zO | Folding all open |
| zc | Folding close |
| [z | start of folding |
| ]z | end of folding |
| zj | next start of folding |
for programmer :
현재 단어의 manpage 보기 : Shift + K
move to matched brace : %, use the command --> d%
현재부터 시작된 {} 안의 내용을 오른쪽 탭으로 밀기 : >i{
현재부터 시작된 {} 까지도 오른쪽 탭으로 밀기 : >%
변수가 선언된 곳으로 가기 : gd, gD
Indenting a block using visual mode
1. Position the cursor on the left or right curly brace.
2. Start visual mode with the v command.
3. Select the inner {} block with the command i}.
4. Indent the text with >.
Complete Words : Ctrl + P
선택구역 한꺼번에 탭 넣기 : v 로 선택후, > 로 탭 넣기
전체 파일 포맷팅 : gg=G
Vim 기능중에 유용한것:
현재 커서 위치에 있는 헤더파일 열기 gf
-> 되돌아 올땐 Ctrl+o
화면 두개로 나누기 :split
지금 소스와 include 된 헤더에서 현재 커서가 있는 토큰이 사용된 모든 라인 보기
Ctrl+[ I
-> 되돌아 올땐 Ctrl+o
ctags사용 쉘에서 ctags -R하여 모든 소스에 대해 인덱스 생성 vi를 실행하고 검색할 단어를 :ta tag로 지정하든지, 단어가 있는 곳에 커서를 둔다. 해당함수(오브젝트)가 정의된 곳으로 가기: Ctrl + ] 되돌아가기: Ctrl + t
| 줄번호 | :set number |
| 자동줄바꿈 - wordwrap | :set wrap :set nowrap |
| 백업폴더 | :set backupdir=/tmp |
c : action like dmotion, but it changes mode to insert mode change upper case and lower case : ~ in find action, next character is special meaning : *[]^%?~$ regular expression : the$ --> 줄의 끝에 있는 the 를 찾아라. include^ --> 줄의 끝에 있는 include 를 찾아라. ^$ --> find the empty line . --> match any single character marks : set mark : ma, mb, mc ...... move to mark : `a, `b, `c, `"(Move to first line in the file) ... delete to mark : d`a show all marks : :marks exit this file and open new file : :vi filename.ext when editing multiple file : show now editing file list : :args next file : :next previous file : :prev first file : :rewind last file : :last Window split : :split splie line up : count[Ctrl+W]- splie line down : count[Ctrl+W]+ splie line same : count[Ctrl+W]= next window : Ctrl+WW