vi 명령어 (AIX 5.3·6.1)

핵심 정리

  • ex 편집기를 바탕으로 한 전체 화면 편집기입니다. vedit는 초보자용 판(report=1, showmode, novice 설정)입니다.
  • 모드는 명령 모드(시작할 때), 입력 모드(a, i, o 등으로 들어가 Esc로 나옴), 마지막 줄 모드(:, /, ?, !)입니다.
  • 이동: h·j·k·l, w·b·e, 0·^·$, G(줄 번호), /패턴·n. 편집: x, dd, dw, cw, yy(Y)·p, u, ..
  • 저장과 끝내기: :w, :q, :q!, ZZ. 다른 파일: :e 파일, :n, :r 파일. 셸: :!명령, :sh.
  • :set 옵션(예: :set nu, :set ic, :set ai)으로 설정하고, 늘 쓸 설정은 EXINIT 변수나 $HOME/.exrc에 넣습니다.
  • 한도: 편집 버퍼 2GB, 줄 1,048,560개(-y로 늘림). AIX 5.3과 6.1 문서의 내용이 같습니다.
항목 내용
버전 AIX 5.3, AIX 6.1 (두 버전 내용 같음)
원문 IBM Commands Reference — 5.3 Volume 6, 6.1 Volume 6
파일 /usr/bin/vi, $HOME/.exrc, $HOME/.vi_history
관련 명령어 vedit, view, ex, ed, ctags, tvi

목적

전체 화면으로 파일을 편집합니다.

영어 원문

Edits files with a full-screen display.

구문

text
{ vi | vedit } [ -l ] [ -R ] [ -t Tag ] [ -v ] [ -w Number ] [ -y Number ] [ -r [ File ] ]
               [ { + | -c } { Subcommand } ] [ File ... ]

설명

vi 명령은 바탕이 되는 ex 편집기를 기반으로 한 전체 화면 편집기를 시작합니다. 그래서 vi 안에서 ex 하위 명령을 쓸 수 있습니다. vedit 명령은 초보자를 위한 판의 vi를 시작합니다. vedit에서는 report 옵션이 1로, showmode와 novice 옵션이 켜져 있어 줄 편집기처럼 됩니다.

편집할 파일의 이름을 지정해 vi를 시작합니다. 명령줄에 File을 둘 이상 주면 지정한 순서대로 편집합니다. 기존 파일을 열면 화면 맨 아래에 파일 이름, 줄 수, 문자 수를 보여 줍니다. 다중 바이트 로캘에서는 문자 수를 바이트 수로 읽어야 합니다.

vi는 전체 화면 편집기라 화면 단위로 글을 편집할 수 있습니다. 편집하는 파일의 사본을 편집 버퍼에 만들고, 바뀐 내용을 저장할 때까지 원래 파일은 바뀌지 않습니다. 화면의 커서 위치가 파일 안의 위치이며, 하위 명령은 커서 위치에서 파일에 작용합니다.

vi의 한도

다음은 vi의 최대 한도입니다(단일 바이트 문자 기준).

  • 전역 명령 목록 하나에 256자
  • 셸 이스케이프 명령에 2,048자
  • 문자열 값 옵션에 128자
  • 태그 이름에 30자
  • 맵 매크로 128개, 모두 합쳐 2,048자
  • 줄 1,048,560개(넘으면 말없이 제한)
  • 매크로 이름과 매크로 내용은 100자까지

참고: 편집 버퍼는 최대 2GB입니다.

편집 모드

모드 설명
명령 모드 vi를 시작하면 명령 모드입니다. 입력 모드에서만 쓰는 것을 빼고 어떤 하위 명령이든 입력할 수 있습니다. 하위 명령이나 다른 모드가 끝나면 명령 모드로 돌아옵니다. 하위 명령을 취소하려면 Esc 키를 누릅니다.
입력 모드 글을 더하는 모드입니다. a, A, i, I, o, O, cx(x는 범위), C, s, S, R 하위 명령으로 들어갑니다. 명령 모드로 돌아가려면 Esc(정상)나 Interrupt(Ctrl-C, 비정상 종료)를 누릅니다.
마지막 줄 모드 :(쌍점), /(슬래시), ?(물음표), !(느낌표), !!로 시작하는 하위 명령은 화면 맨 아래 줄에서 입력을 받습니다. 첫 글자를 누르면 커서가 맨 아래로 가고, 나머지를 입력한 뒤 Enter로 실행하거나 Interrupt(Ctrl-C)로 취소합니다. !!는 느낌표 두 개를 다 입력한 뒤에 커서가 움직입니다.

:로 마지막 줄 모드에 들어가 범위를 받는 명령 앞에 쓰면 다음 문자가 특별한 뜻을 갖습니다: %(커서 위치와 상관없이 모든 줄), $(마지막 줄), .(현재 줄).

참고: 마지막 줄 모드 하위 명령의 기록은 위·아래 화살표 키로 오갈 수 있습니다.

vi 맞춤 설정

옵션 설정, 매크로 정의, 키 매핑, 약어 설정으로 vi를 맞출 수 있습니다.

vi 옵션 설정

다음 옵션은 set 명령으로 바꿉니다. 켜고 끄는 옵션은 기본이 꺼짐이며(표에 기본값을 따로 적은 것은 예외), 켠 옵션은 이름 앞에 no를 붙여 끕니다. 예를 들어 autowrite를 끄려면 noaw를 입력합니다. 옵션을 입력할 때 괄호는 넣지 않습니다.

옵션(약어) 설명
autoindent (ai) 입력 모드에서 앞 줄의 들여쓰기에 맞춰 자동으로 들여 씁니다(간격은 shiftwidth). 이전 탭 위치로 돌아가려면 Ctrl-D를 누릅니다. 전역 명령에는 적용되지 않습니다. 기본은 noai.
autoprint (ap) 편집 버퍼를 바꾸는 명령 뒤에 현재 줄을 출력합니다. 한 줄에 여러 명령이 있으면 마지막 명령에만 적용되고, 전역 명령에는 적용되지 않습니다. 기본은 ap.
autowrite (aw) 마지막 쓰기 뒤에 편집 버퍼가 바뀌었으면, :n, :ta, Ctrl-A, Ctrl-], Ctrl-T, ! 전에 버퍼를 자동으로 파일에 씁니다. 기본은 noaw.
backtags (bt) Ctrl-T가 앞서 Ctrl-]를 실행한 위치로 돌아가게 합니다. nobacktags면 Ctrl-T는 Ctrl-]와 같습니다. 기본은 backtags.
beautify (bf) 입력 중에 제어 문자(탭, 줄바꿈, 폼 피드 제외)를 편집 버퍼에 넣지 못하게 합니다. 명령 입력에 적용됩니다. 기본은 nobf.
closepunct (cp=) 닫는 구두점 목록을 다룹니다(특히 wraptype으로 줄을 감쌀 때). 여러 글자 구두점 앞에는 글자 수를 씁니다(예: cp=3..;)}). 줄을 감쌀 때 닫는 구두점은 나누지 않습니다.
directory (dir=) 편집 버퍼가 있는 디렉터리입니다. 기본은 dir=/var/tmp.
edcompatible (ed) 여러 번 바꿀 때 g(전역)와 c(확인) 접미사를 유지하고, r 접미사가 r 하위 명령처럼 동작하게 합니다. 기본은 noed.
exrc (exrc) 꺼져 있으면, 현재 디렉터리가 HOME이 아닌 한 초기화할 때 현재 디렉터리의 .exrc를 무시합니다. 기본은 noexrc.
hardtabs (ht=) 화면의 하드웨어 탭 간격입니다. 터미널의 탭 설정과 맞아야 합니다. 기본은 ht=8.
history (hist=) 마지막 줄 모드 기록의 개수 한도입니다. 처음 값은 hist=32이고, tvi에서는 0입니다.
ignorecase (ic) 정규 표현식을 찾을 때 대소문자를 구분하지 않습니다. 기본은 noic.
linelimit (ll=) 최대 줄 수입니다(-y 옵션과 같음). .exrc나 EXINIT에서 쓸 때만 효과가 있습니다.
lisp (lisp) ( ), { }, [[, ]]의 특별한 뜻을 없애고 s-식에 =(서식 출력) 연산자를 쓸 수 있게 해 LISP 프로그램을 편집합니다. 기본은 nolisp.
list (list) 탭을 ^I로, 줄 끝을 $로 표시합니다. 기본은 nolist.
magic (magic) 패턴을 찾을 때 ., [, *를 특수 문자로 다룹니다. 끄면 ( )와 $만 특별한 뜻을 유지하며, 다른 문자는 \(백슬래시)를 앞에 붙여 특별한 뜻을 줄 수 있습니다. 기본은 magic.
mesg (mesg) 비주얼 모드에서 터미널 쓰기 권한을 켭니다. .exrc나 EXINIT에서 쓸 때만 효과가 있습니다. 기본은 켜짐.
modeline (modeline) 파일의 처음 다섯 줄이나 마지막 다섯 줄에 있는 vi 명령 줄을 실행합니다. 줄 안에 빈칸이나 탭 뒤에 ex:나 vi:가 있어야 알아보며, 둘째 :에서 끝납니다. 기본은 nomodeline.
novice novice 모드인지 나타냅니다. set으로 바꿀 수 없습니다.
number (nu) 줄 앞에 줄 번호를 표시합니다. 기본은 nonu.
optimize (opt) 커서 주소 지정이 없는 터미널의 동작을 빠르게 합니다. 기본은 noopt.
paragraphs (para=) 문단을 시작하는 매크로 이름입니다. 기본은 para=IPLPPPQPP LIpplpipnpbp. 한 글자 nroff 매크로(.P 등)는 빈칸을 인용 문자로 넣어야 합니다.
partialchar (pc=) 2칸 너비 문자가 다 표시되지 않는 마지막 열에 보이는 문자입니다. 기본은 -.
prompt 명령 모드에서 :를 출력해 새 명령을 기다립니다. 기본은 켜짐.
readonly (ro) 영구 읽기 전용 모드로 둡니다. 기본은 noreadonly.
redraw (redraw) 기능이 적은 터미널에서 지능형 터미널처럼 보이게 합니다. 기본은 nore.
remap 다른 매크로로 매크로를 정의할 수 있게 합니다. 기본은 켜짐.
report (re=) 몇 줄 넘게 바뀌어야 메시지를 낼지 정합니다. 전역 명령처럼 메시지가 많은 명령은 끝난 뒤에 보여 줍니다. 기본은 report=5.
scroll (scr=) 위아래로 스크롤할 줄 수입니다. 기본은 창 크기의 절반(내림).
sections (sect=) 절을 시작하는 매크로 이름입니다. 기본은 sect=NHSHHH HUuhsh+c.
shell (sh=) !와 :!에 쓸 셸입니다. 기본은 로그인 셸.
shiftwidth (sw=) autoindent, 이동 명령(>, <), 입력 명령(Ctrl-D, Ctrl-T)이 쓰는 소프트 탭 간격입니다. 줄 앞의 들여쓰기에만 영향을 줍니다. 기본은 sw=8.
showmatch (sm) )나 }를 입력할 때 짝이 되는 (나 {를 보여 줍니다. 기본은 nosm.
showmode (smd) 입력 모드일 때 메시지로 알려 줍니다. 기본은 nosmd.
slowopen (slow) 입력하는 동안 화면 갱신을 늦춥니다. 기본은 noslow.
tabstop (ts=) 표시하는 파일의 탭 간격입니다. 기본은 ts=8.
tags (tags=) ctags로 만든 함수 이름 데이터베이스 파일의 검색 경로입니다. 기본은 tags=tags /usr/lib/tags.
term (term=) 쓰는 워크스테이션의 형식입니다. 기본은 term=$TERM(TERM 셸 변수 값).
terse (terse) 메시지를 짧게 보여 줍니다. 기본은 noterse.
timeout (to) 문자 입력에 2초 시간 제한을 둡니다. 켜져 있으면 매크로의 문자를 따로따로 입력해 처리할 수 있습니다. 매크로를 다시 쓰려면 notimeout으로 둡니다. 기본은 to.
ttytype 쓰는 터미널의 tty 형식입니다. vi에서 바꿀 수 없습니다.
warn (warn) 편집 버퍼를 바꾸고 저장하지 않은 뒤 처음으로 !로 셸 명령을 실행할 때 경고 메시지를 보여 줍니다. 기본은 warn.
window (wi=) 한 창에 보이는 줄 수입니다. 기본값은 통신 속도에 따라 600보 이하 8줄, 1200보 16줄, 그보다 빠르면 전체 화면에서 1줄 뺀 값입니다.
wrapmargin (wm=) 다음 줄로 자동 줄 바꿈할 여백입니다. 0이면 자동 줄 바꿈을 끕니다. 기본은 wm=0.
wrapscan (ws) 문자열을 찾을 때 편집 버퍼 끝에서 처음으로 돌아가 계속 찾습니다. 기본은 ws.
wraptype (wt=) 줄 끝에서 단어를 감싸는 방법입니다. general(기본, 두 문자 사이의 공백에서), word(단어 단위), rigid(열 기준, 닫는 구두점 앞에서), flexible(열 기준, 구두점 한 글자는 여백을 넘을 수 있음) 중 하나입니다.
writeany (wa) 쓰기 하위 명령 전에 보통 하는 검사를 끕니다. 기본은 nowa.

옵션을 다루는 방법:

입력 결과
set 뒤 스페이스바 기본값에서 바뀐 설정을 보여 줍니다. Enter로 명령 모드에 돌아갑니다.
set all 모든 설정을 보여 줍니다.
set Option 옵션을 켭니다.
set Option Option Option 옵션 여러 개를 켭니다.
set noOption 옵션을 끕니다.
set Option=Value 옵션 값을 바꿉니다.
  • :set은 이번 편집 세션에만 적용됩니다.
  • 모든 세션에 적용하려면 .profile(로그인할 때 셸이 읽음)의 EXINIT 환경 변수에 :set을 넣거나, .exrc 파일에 set을 넣습니다.
  • vi는 먼저 EXINIT를 찾아 실행하고, 없으면 $HOME/.exrc를 실행합니다. 마지막으로, 앞의 결과와 상관없이 현재 디렉터리의 .exrc를 찾아 실행합니다.
  • 참고: tvi(trusted vi)는 예외로 /etc/.exrc만 찾아 실행합니다.
  • .exrc에는 set Option=Value 형태의 하위 명령을 넣을 수 있습니다(예: set cp=3 . . ;). 줄의 첫 글자를 "(큰따옴표)로 하면 주석입니다.

매크로 정의

자주 쓰는 하위 명령이나 그 묶음은 매크로로 정의할 수 있습니다. 하위 명령을 영문자 이름의 버퍼에 넣습니다. 소문자 az는 버퍼 내용을 덮어쓰고, 대문자 AZ는 이전 내용 뒤에 덧붙여 매크로를 조금씩 만들 수 있습니다.

  • 예: corner라는 단어를 찾아 그 셋째 줄 아래를 현재 줄로 하는 매크로 c를 정의하려면 o /corner/+3를 입력하고 Esc를 누른 뒤 "c를 입력합니다. 여기서 원문은 이어서 줄을 버퍼로 옮기는 명령을 생략했습니다(아래 원문과 다른 점 참고).
  • 덧붙이기: o viSubcommand를 입력하고 Esc를 누른 뒤 "대문자를 입력합니다. 예를 들어 o corner, Esc, "T로 매크로 T를 만들고, o -dd(위 줄로 가서 지우기), Esc, "Tdd로 명령을 더합니다.
  • 실행: @글자로 매크로를 실행하고, @@로 같은 매크로를 다시 실행합니다.

시스템의 문자 집합은 대조 표가 정하며, 이 표가 vi 매크로의 성능에 영향을 줍니다.

키 매핑

:map, :map!, :ab 하위 명령으로 키 하나에 명령이나 명령 묶음을 매핑합니다. :map은 명령 모드에서, :map!과 :ab는 입력 모드에서 씁니다. 모든 세션에 적용하려면 $HOME/.exrc에 넣고, 이번 세션에만 적용하려면 편집 중에 입력합니다.

주의: IBM 3161, 3163, 3101 ASCII 디스플레이 스테이션에서는 vi의 기본 키 매핑 때문에 데이터를 잃을 수 있습니다. 특히 Esc-J나 Shift-J는 커서 위치부터 파일 끝까지 모두 지웁니다. :map으로 기본 매핑을 확인하고 .exrc로 바꿉니다.

:map(명령 모드 매크로)

  • :map Letter viSubcommand로 문자에 편집 명령 묶음을 매핑하고, :unmap Letter로 풀고, :map으로 목록을 봅니다.
  • vi가 쓰지 않아 매핑에 쓸 수 있는 키: 글자 g, K, q, V, v, Ctrl-A, Ctrl-K, Ctrl-O, Ctrl-W, Ctrl-X, 기호 _, *, \, =(LISP 모드에서는 = 불가). 이미 쓰는 키를 매핑하면 매핑이 있는 동안 원래 기능을 쓸 수 없습니다.
  • Enter, Esc, Backspace, Delete 키는 매핑할 때 앞에 Ctrl-V를 붙여야 vi가 해석하지 않습니다.
  • Ctrl-T, Ctrl-W, Ctrl-X는 Ctrl-V로 먼저 이스케이프하고, 파이프 기호는 Ctrl-V를 두 번 붙입니다.
  • 기능 키는 #번호로 가리킵니다. terminfo의 kf1, kf2 같은 항목과 터미널이 보내는 값이 맞아야 합니다.
text
:map v /map<Ctrl-V><Enter>cwMAP<Ctrl-V><Esc><Ctrl-V><Enter>
:map <Ctrl-A> :w<Ctrl-V><Enter>:n<Ctrl-V><Enter>
:map g :!cat /etc/motd <Ctrl-V><Ctrl-V>| wc<Ctrl-V><Enter>
:map #1 dwwww
:map <Ctrl-V><End> G
:map <Ctrl-V><Home> 1G
:map <Ctrl-V><PageUp> <Ctrl-F>
:map <Ctrl-V><PageDown> <Ctrl-B>
  • 첫 줄은 v에 "다음 map을 찾아(/map) MAP으로 바꾸기(cwMAP)"를, 둘째 줄은 Ctrl-A에 "저장하고 다음 파일 편집"을, 셋째 줄은 g에 "/etc/motd를 wc로 넘기기"를, 넷째 줄은 F1에 "단어를 지우고 세 단어 앞으로"를 매핑합니다.
  • 대부분의 터미널에서 Home, End, Page Up, Page Down은 이미 매핑돼 있으며, 안 돼 있으면 마지막 네 줄처럼 매핑합니다.
  • :map 목록에서 Ctrl-V와 Enter는 Ctrl-M으로, Ctrl-V와 Esc는 Ctrl-[로 보입니다.

:map!(입력 모드 매핑)

  • :map! Letter String으로 입력 모드에서 글자를 문자열로 매핑하고, :unmap! Letter로 풀고, :map!으로 목록을 봅니다.
  • 예: :map! % <Ctrl-V><Esc>bbwcw는 입력 중에 %를 누르면 명령 모드로 나가 현재 단어 처음으로 가서(bbw) 단어 바꾸기(cw)를 시작합니다. 잘못 친 단어를 바로 다시 칠 수 있습니다.
  • 중요: 한번 매핑한 키는 :unmap!을 하기 전에는 글자로 입력할 수 없으니 키를 신중하게 고릅니다.

:ab(약어)

  • 입력 모드에서 키나 키 묶음을 문자열로 바꿉니다. 같은 구절, 이름, 제목을 되풀이해 입력할 때 좋습니다.
  • 예: :ab city Austin, Texas 78759를 정하면, 입력 중에 city 뒤에 공백·마침표·쉼표를 치면 Austin, Texas 78759로 펼쳐집니다. My current residence is city.는 My current residence is Austin, Texas 78759.가 됩니다.
  • 단어 안에서는 펼치지 않습니다(iscity는 그대로). 같은 것을 :map!으로 정하면 앞뒤와 상관없이 늘 펼쳐져 iscity가 isAustin, Texas 78759가 됩니다.
  • 중요: 한번 정한 약어는 :unab을 하기 전에는 그 글자로 입력할 수 없습니다.

약어 설정

약어는 map!과 비슷하지만 약어가 따로 떨어진 단어일 때만 바꿉니다. 빈 편집 버퍼로 vi를 시작하고 Esc로 명령 모드인지 확인한 뒤 씁니다.

하는 일 방법
약어 목록 보기 :ab를 입력합니다. Enter로 명령 모드에 돌아갑니다.
약어 지우기 :unab Abbreviation을 입력합니다.
약어 정하기 :ab Abbreviation String을 입력합니다. 예를 들어 :ab kn upper를 정한 뒤 acknowledge를 치면 kn이 따로 떨어진 단어가 아니라 바뀌지 않고, make the kn line all kncase를 치면 make the upper line all uppercase가 됩니다.
영어 원문

The vi command starts a full-screen editor based on the underlying ex editor. Therefore, ex subcommands can be used within the vi editor. The vedit command starts a version of the vi editor intended for beginners. In the vedit editor, the report option is set to 1, the showmode option is set, and the novice option is set, making it a line editor.

You start the vi editor by specifying the name of the file or files to be edited. If you supply more than one File parameter on the command line, the vi editor edits each file in the specified order. The vi editor

on an existing file displays the name of the file, the number of lines, and the number of characters at the bottom of the screen. In case of multibyte locales the number of characters need to be interpreted as the number of bytes.

Since the vi editor is a full-screen editor, you can edit text on a screen-by-screen basis. The vi editor makes a copy of the file you are editing in an edit buffer, and the contents of the file are not changed until you save the changes. The position of the cursor on the display screen indicates its position within the file, and the subcommands affect the file at the cursor position.

vi Editor Limitations

The following list provides the maximum limits of the vi editor. These counts assume single-byte characters.

  • 256 characters per global command list

  • 2048 characters in a shell escape command

  • 128 characters in a string-valued option

  • 30 characters in a tag name

  • 128 map macros with 2048 characters total

  • 1,048,560 lines silently enforced

  • The macro name and the macro text are limited to 100 characters.

Note: The vi editor supports a maximum of 2 GB edit buffer.

vi Editing Modes

The vi editor operates in the following modes:

  • command mode — When you start the vi editor, it is in command mode. You can enter any subcommand except those designated for use only in the text input mode. The vi editor returns to command mode when subcommands and other modes end. Press the Esc key to cancel a subcommand.
  • text-input mode — You use the vi editor in this mode to add text. Enter text input mode with any of the following subcommands: the a subcommand, A subcommand, i subcommand, I subcommand, o subcommand, O subcommand, cx subcommands (where the x represents the scope of the subcommand), C subcommand, s subcommand, S subcommand, and R subcommand. After entering one of these subcommands, you can enter text into the editing buffer. To return to command mode, press the Esc key for normal exit or press Interrupt (the Ctrl-C key sequence) to end abnormally.
  • last-line mode — Subcommands with the prefix : (colon), / (slash), ? (question mark), ! (exclamation point), or !! (two exclamation points) read input on a line displayed at the bottom of the screen. When you enter the initial character, the vi editor places the cursor at the bottom of the screen, where you enter the remaining characters of the command. Press the Enter key to run the subcommand, or press Interrupt (the Ctrl-C key sequence) to cancel it. When the !! prefix is used, the cursor moves only after both exclamation points are entered. When you use the : prefix to enter the last-line mode, the vi editor gives special meaning to the following characters when they are used before commands that specify counts: % All lines regardless of cursor position $ Last line . Current line Note: The history of last line mode subcommands can be navigated using the Up and Down Arrow keys.
  • Customizing the vi Editor

You can customize the vi editor by:

  • Setting vi editor options

  • Defining macros

  • Mapping keys

  • Setting abbreviations

Setting vi Editor Options

The following list describes the vi editor options you can change with the set command. The default setting for these options is off. If you turn on one of these toggle options, you can turn it off again by entering the word no before the option. If you want to discontinue the autowrite vi option, enter noaw, where no turns off the option and aw specifies the autowrite option.

Note: Do not include parentheses when entering vi options.

vi Option (Abbreviation) Description autoindent (ai) Indents automatically in text input mode to the indentation of the previous line by using the spacing between tab stops specified by the shiftwidth option. The default is noai. To back the cursor up to the previous tab stop, press the Ctrl-D key sequence. This option is not in effect for global commands. autoprin (ap) Prints the current line after any command that changes the editing buffer. The default is ap. This option applies only to the last command in a sequence of commands on a single line and is not in effect for global commands. autowrite (aw) Writes the editing buffer to the file automatically before the :n subcommand, the :ta subcommand, the Ctrl-A, Ctrl -], and Ctrl -T key sequences, and the ! subcommand if the editing buffer changed since the last write subcommand. The default is noaw. backtags (bt) Allows the Ctrl-T subcommand to return the file editing position to the location where the previous Ctrl-] subcommand was issued. If nobacktags is set, then Ctrl-T is the same as Ctrl-]. The default is backtags. beautifying text (bf) Prevents the user from entering control characters in the editing buffer during text entry (except for tab, new-line, and form-feed indicators). The default is nobf. This option applies to command input. closepunct (cp=) Handles a list of closing punctuation, especially when wrapping text (wraptype option). Precedes multicharacter punctuation with the number of characters; for example, cp=3..;)}. The vi command does not split closing punctuation when wrapping. directory (dir=) Displays the directory that contains the editing buffer. The default is dir = /var/tmp. edcompatible (ed) Retains g (global) and c (confirm) subcommand suffixes during multiple substitutions and causes the r (read) suffix to work like the r subcommand. The default is noed. exrc (exrc) If not set, ignores any .exrc file in the current directory during initialization, unless the current directory is that named by the HOME environment variable. The default is noexrc. hardtabs (ht=) Tells the vi editor the distance between the hardware tab stops on your display screen. (This option must match the tab setting of the underlying terminal or terminal emulator.) The default is ht=8. history (hist=) Sets the limit on last line mode history commands. The initial value is hist=32. The history size is zero (hist=0) for the tvi command. ignorecase (ic) Ignores distinction between uppercase and lowercase while searching for regular expressions. The default is noic. linelimit (ll=) Sets the maximum number of lines, as per the -y command-line option. This option only is effective if used with the .exrc file or the EXINIT environment variable. lisp (lisp) Removes the special meaning of ( ), , [ [, and ] ] and enables the = (formatted print) operator for s-expressions, so you can edit list processing (LISP) programs. The default is nolisp. list (list) Displays text with tabs (^I) and the marked end of lines ($). The default is nolist.

vi Option (Abbreviation) Description magic (magic) Treats the . (period), [ (left bracket), and * (asterisk) characters as special characters when searching for a pattern. In off mode, only the ( ) (parentheses) and $ (dollar sign) retain special meanings. However, you can evoke special meaning in other characters by preceding them with a \ (backslash). The default is magic. mesg (mesg) Turns on write permission to the terminal if set while in visual mode. This option only is effective if used with the .exrc file or the EXINIT environment variable. The default is on. modeline (modeline) Runs a vi editor command line if found in the first five or the last five lines of the file. A vi editor command line can be anywhere in a line. For the vi editor to recognize a command line, the line must contain a space or a tab followed by the ex: or vi: string. The command line is ended by a second : (colon). The vi editor tries to interpret any data between the first and second colon as vi editor commands. The default is nomodeline. novice Indicates whether you are in novice mode. You cannot change the value by using the set command. number (nu) Displays lines prefixed with their line numbers. The default is nonu. optimize (opt) Speeds the operation of terminals that lack cursor addressing. The default is noopt. paragraphs (para=) Defines vi macro names that start paragraphs. The default is para=IPLPPPQPP\ LIpplpipnpbp. Single-letter nroff macros, such as the .P macro, must include the space as a quoted character if respecifying a paragraph. partialchar (pc=) Appears in the last display column where a double-wide character would not be displayed completely. The default character is - (minus sign). prompt Prompts for a new vi editor command when in command mode by printing a : (colon). The default is on. readonly (ro) Sets permanent read-only mode. The default is noreadonly. redraw (redraw) Simulates a smart workstation on a dumb workstation. The default is nore. remap Allows defining macros in terms of other macros. The default is on. report (re=) Sets the number of times you can repeat a command before a message is displayed. For subcommands that produce many messages, such as global subcommands, the messages are displayed when the command sequence completes. The default is report=5. scroll (scr=) Sets the number of lines to be scrolled when the user scrolls up or down. The default is 1/2 of the window size, rounded down. sections (sect=) Defines vi macro names that start sections. The default is sect=NHSHHH\ HUuhsh+c. Single-letter nroff macros, such as the .P macro, must include the space as a quoted character if respecifying a paragraph. shell (sh=) Defines the shell for the ! subcommand or the :! subcommand. The default is the login shell. shiftwidth (sw=) Sets the distance for the software tab stops used by the autoindent option, the shift commands ( > and < ), and the text input commands ( the Ctrl-D and Ctrl-T key sequences). This vi option only affects the indentation at the beginning of a line. The default is sw=8. showmatch (sm) Shows the ( (matching left parenthesis) or { (left bracket) as you type the ) (right parenthesis) or } (right bracket). The default is nosm. showmode (smd) Displays a message to indicate when the vi editor is in input mode. The default is nosmd. slowopen (slow) Postpones updating the display screen during inserts. The default is noslow. tabstop (ts=) Sets the distance between tab stops in a displayed file. The default is ts=8. tags (tags =) Defines the search path for the database file of function names created using the ctags command. The default is tags=tags\ /usr/lib/tags. term (term=) Sets the type of workstation you are using. The default is term=$TERM, where $TERM is the value of the TERM shell variable. terse (terse) Allows the vi editor to display the short form of messages. The default is noterse. timeout (to) Sets a time limit of two seconds on an entry of characters. This limit allows the characters in a macro to be entered and processed as separate characters when the timeout option is set. To resume use of the macro, set the notimeout option. The default is to.

vi Option (Abbreviation) Description ttytype Indicates the tty type for the terminal being used. You cannot change this value from the vi editor. warn (warn) Displays a warning message before the ! subcommand executes a shell command if it is the first time you issued a shell command after changes were made in the editing buffer but not written to a file. The default is warn. window (wi=) Sets the number of lines displayed in one window of text. The default depends on the baud rate at which you are operating: 600 baud or less, 8 lines; 1200 baud, 16 lines; higher speeds, full screen minus 1 line. wrapmargin (wm=) Sets the margin for automatic word wrapping from one line to the next. The default is wm=0. A value of 0 turns off word wrapping. wrapscan (ws) Allows string searches to wrap from the end of the editing buffer to the beginning. The default is ws. wraptype (wt=) Indicates the method used to wrap words at the end of a line. The default value is general. You can specify one of the following four values: general Allows wraps on word breaks as white space between two characters. This setting is the default. word Allows wraps on words. rigid Allows wraps on columns and before closing punctuation. flexible Allows wraps on columns, but one character of punctuation can extend past the margin. writeany (wa) Turns off the checks usually made before a write subcommand. The default is nowa.

To see a list of the vi editor settings that have changed from the default settings, enter set and press the spacebar. Press the Enter key to return to the command mode.

To see a complete list of the vi editor settings, enter set all. Press the Enter key to return to the command mode.

To turn on a vi editor option, enter set Option. This command automatically returns you to the command mode.

To turn on multiple vi editor options, enter set Option Option Option. This command turns on the three designated vi editor options and returns you to the command mode.

To turn off a vi editor option, enter set noOption. This command automatically returns you to the command mode.

To change the value of a vi editor option, enter set Option=Value. This command automatically returns you to the command mode.

You can use the :set subcommand of the vi editor to set options for this editing session only, or to set options for this editing session and all future editing sessions.

To set or change vi editor options for this editing session only, enter the :set subcommand from the command line.

To set vi options for all editing sessions, put the :set subcommand in the EXINIT environment variable in the .profile file (read by the shell on login) or put the set subcommand into a .exrc file. The vi editor first looks for the EXINIT environment variable and runs its commands. If the EXINIT environment variable does not exist, the vi editor then looks for the $HOME/.exrc file and runs its commands. Last, and regardless of any previous results, the vi editor looks for the local .exrc file and runs its commands.

Note: This process is true except with the tvi command (trusted vi). In this instance, the vi editor looks for and runs only the /etc/.exrc file.

For information about changing an option by setting the EXINIT environment variable, see the description of environment variables in the environment file.

The .exrc file can contain subcommands of the form set Option=Value; for example: set cp=3 . . ;

To include a comment in the .exrc file, use a " (double quotation mark) as the first character in the line.

Defining Macros

If you use a subcommand or sequence of subcommands frequently, you can use the vi editor to define a macro that issues that subcommand or sequence.

To define a macro, enter the sequence of subcommands into a buffer named with a letter of the alphabet. The lowercase letters a through z overlay the contents of the buffer, and the uppercase letters A through Z append text to the previous contents of the buffer, allowing you to build a macro piece by piece.

For example, to define a buffer macro named c that searches for the word corner and makes the third line after the word corner the current line, enter the following command: o /corner/+3

Then press the Esc key and enter the following command: "c

where c is the name of the buffer macro.

To add text to the previous contents of the defined buffer, enter the o viSubcommand, press the Esc key, and enter "CapitalLetter, where the CapitalLetter variable specifies an uppercase letter A through Z. For example, to build a buffer macro named T that searches for the word corner and allows you to add more commands, enter the following command: o corner

Then press the Esc key and enter the following command: "T

where T is the name of the buffer macro. You can repeat this process at any time to add more vi subcommands to the same buffer.

For example, to add commands that move the cursor to the previous line and delete that line, enter the following command: o -dd

where - (minus sign) means to move the cursor up one line, and dd means to delete the current line. Press the Esc key and enter the following command: "Tdd

To start the macro, enter @Letter, where the Letter variable specifies the letter name of the buffer macro you want to use. To use the same macro again, enter @@ (two at symbols). For example, enter @T to start the T buffer macro and run the search, move cursor, and delete line commands. Enter @@T to start the T buffer macro again.

The character set used by your system is defined by the collation table. This table affects the performance of vi macros.

Mapping Keys

You can use the :map, :map!, and :ab subcommands to map a keystroke to a command or a sequence of commands. The :map subcommand is used in the command mode. The :map! and :ab subcommands are used in the text input mode. You can map keys for this editing session and all future editing sessions or only for the current editing session from either mode.

To map keys for all future editing sessions, put the subcommand into a $HOME/.exrc file. Each time you start the vi editor, it reads this file. The mapping remains in effect for every editing session.

To map keys for the current editing session only from the command mode, start the subcommand during the vi editor session. To map keys for the current editing session only from the text input mode, enter the subcommand on the command line during the vi editor session. The mapping remains in effect only for the current editing session.

Attention: If you use an IBM® 3161 ASCII display station, IBM 3163 ASCII display station, or IBM 3101 ASCII display station, the default key-mapping of the vi editor can cause you to lose data. To see the default mapping, issue a :map subcommand. Specific problems arise with the Esc-J or Shift-J key sequence. These key sequences delete all information from the current position of the cursor to the end of the file. To avoid problems, change this key sequence using a .exrc file.

The :map, :map!, and :ab subcommands are defined and used as follows:

  • :map — Defines macros in the command mode. The :map subcommand allows you to run a specified command or sequence of commands by pressing a single key while in the vi editor. To map keys in the command mode, start the vi editor with an empty editing buffer and do not name a vi file using the vi command or type anything into the buffer after the vi editor starts. You can use the :map subcommand to do the following: • To map a character to a sequence of editing commands, enter: :map Letter viSubcommand • To unmap a character previously mapped in command mode, enter: :unmap Letter • To display a list of current mappings for the command mode, enter :map The following keys are not used by the vi editor, but are available for use with the :map subcommand in the command mode: • Letters g, K, q, V, and v • Control key sequences Ctrl-A, Ctrl-K, Ctrl-O, Ctrl-W, and Ctrl-X • Symbols _ (underscore), * (asterisk), \ (backslash), and = (equal sign) Although you can map a key that is already used by the vi editor, the key's usual function is not available as long as the map is in effect. Some terminals allow you to map command sequences to function keys. If you are in LISP mode, the = (equal sign) cannot be used because it is used by the vi editor. To map the letter v to the sequence of commands that would locate the next occurrence of the word map and change it to the word MAP, enter the following command: :map v /map<Ctrl-V><Enter>cwMAP<Ctrl-V><Esc><Ctrl-V><Enter> The previous example instructs the vi editor to locate the next occurrence of map (/map<Ctrl-V><Enter>), change map to MAP (cwMAP), end the change-word subcommand (<Ctrl-V><Esc>), and enter the command (<``Ctrl-V><Enter>). Requirement: To prevent the vi editor from interpreting the Enter key, it must be preceded by the Ctrl-V key sequence when being mapped. This condition is also true of the Esc, Backspace, and Delete keys. To map the control characters Ctrl-A, Ctrl-K, and Ctrl-O, simultaneously press the Ctrl key and the letter. For example, to map the Ctrl-A key sequence to the sequence of commands that saves a file and edits the next one in a series, enter the following command: :map <Ctrl-A> :w<Ctrl-V><Enter>:n<Ctrl-V><Enter> To map the control characters Ctrl-T, Ctrl-W, and Ctrl-X, you must first escape them with the Ctrl-V key sequence. To map the | (pipe symbol), you must first escape it with the two Ctrl-V key sequences, as illustrated by the following example that maps the character g to the sequence of commands that escapes to the shell, concatenates the file /etc/motd, and pipes the output to the wc command: :map g :!cat /etc/motd <Ctrl-V><Ctrl-V>| wc<Ctrl-V><Enter> If your terminal permits you to map function keys, you must reference them with the #number key sequence to designate the number of the function key that you want to map. In the following example, the F1 function key is mapped to the sequence of commands that deletes a word and moves the cursor three words down: :map #1 dwwww In order for function key mapping to work, the output of the function key for your terminal type must match the output defined in the terminfo file. These definitions are denoted by the kfnumber entries, where kf1 represents the F1 function key, kf2 represents the F2 function key, and so on. If the output that you get when you press the function key does not match this entry, you must use the terminal's setup mode to correct the settings to match these terminal database entries before any mapping can occur. You can also map certain keyboard special keys, such as the Home, End, Page Up, and Page Down keys. For most terminals, these keys are already mapped in the vi editor. You can verify this mapping by using the :map subcommand. If these keys are not already mapped, you can use the :map subcommand as follows: :map <Ctrl-V><End> G :map <Ctrl-V><Home> 1G :map <Ctrl-V><PageUp> <Ctrl-F> :map <Ctrl-V><PageDown> <Ctrl-B> To get a listing of all current maps in the command mode, enter the :map subcommand. The preceding examples are then displayed as follows: v v /map<Ctrl-M>cwMAP<Ctrl-[>Ctrl-M> <Ctrl-A> <Ctrl-A> :w<Ctrl-M>:n<Ctrl-M> g g :!cat /etc/motd | wc <Ctrl-M> Tip: The Ctrl-V and Enter key sequence is displayed as the Ctrl-M key sequence, and the Ctrl-V and Esc key sequence is displayed as the Ctrl-[ key sequence.
  • :map! — Maps character strings to single keys while in text input mode. To map keys in the text input mode, start the vi editor with an empty editing buffer and do not name a vi file using the vi command or type anything into the buffer after the vi editor starts. You can use the :map! subcommand to do the following: • To map a letter to one or more vi strings in text input mode, enter: :map! Letter String • To unmap a letter previously mapped in text input mode, enter: :unmap! Letter • To display a list of existing strings that are mapped to specific keys in text input mode, enter: :map! Typing the mapped key while in text input mode produces the specified string. The Ctrl-V and Esc key sequence puts you into command mode, backs up to the beginning of the current word (bbw), and starts the cw (change-word) subcommand. For example: :map! % <Ctrl-V><Esc>bbwcw When typing text, if you realize that you have mistyped a word, you can change it by pressing the % (percent) key and retyping the word. You are automatically returned to insert mode. Important: Be careful when choosing keys to be used for the :map! subcommand. Once keys have been mapped, they can no longer be input as text without first issuing the :unmap! subcommand.
  • :ab — Maps a key or sequence of keys to a string of characters for use in the text input mode. The :ab subcommand is useful when inputting text that possesses several repetitive phrases, names, or titles. The following example replaces the word city with the phrase Austin, Texas 78759 whenever it is typed in text input mode and followed by a white space, period, or comma: :ab city Austin, Texas 78759 For example, if while inputting text, you type the following: My current residence is city. Pressing the Tab key expands the word city to read: My current residence is Austin, Texas 78759. The abbreviation is not expanded within a word. For example, if you type My current residence iscity, the word iscity is not expanded. If the :map! subcommand is used to map abbreviations for insert mode, then all occurrences of the abbreviations are expanded regardless of where it occurs. If you used the :map! subcommand for the preceding example (:map! city Austin, Texas 78759), then whenever you type the word city, regardless of what precedes or follows, the word will be expanded to Austin, Texas 78759. Therefore, the word iscity becomes isAustin, Texas 78759. Important: Be careful when choosing the keys that are used for the :ab subcommand. Once keys are defined, they can no longer be input as text without first issuing the :unab subcommand.
  • Setting Abbreviations

The set command has behavior similar to the map! command except that the set command substitutes the string for the abbreviation only when the abbreviation is a separate word. You can use the set command of the vi editor to:

  • List existing abbreviations

  • Remove an abbreviation

  • Set (define) an abbreviation

Tip: Start the vi editor with an empty editing buffer. Do not name a vi file using the vi command or type anything into the buffer after the vi editor starts. Press the Esc key to be sure you are in the command mode.

  • To list abbreviations — Enter the :ab command to list existing abbreviations. Press the Enter key to return to command mode.
  • To remove abbreviations — Enter the :anabAbbreviation command to remove an abbreviation, where the Abbreviation variable specifies the character string you do not want abbreviated any more.
  • To set (define) an abbreviation — Enter the :ab Abbreviation String command to set an abbreviation, where the Abbreviation variable specifies the character string being defined as an abbreviation and the String variable specifies the character string being abbreviated. The abbreviation can be substituted for the string only when the abbreviation is a separate word. For example, if you enter the :ab kn upper command and then type acknowledge while in the text input mode, the set abbreviation string is not started because the kn string in the word acknowledge is not a separate word. However, if you type the :ab kn upper command and then type make the kn line all kncase while in the text input mode, the result is make the upper line all uppercase.

플래그

플래그 설명
-c Subcommand vi로 보기 시작하기 전에 ex 하위 명령을 실행합니다. 커서는 마지막으로 실행한 하위 명령이 영향을 준 줄로 갑니다. -c ''처럼 빈 피연산자를 주면 파일의 첫 줄에 커서를 둡니다. +와 함께 쓸 수 없습니다.
-l LISP 모드로 시작합니다. LISP 코드에 맞게 들여 쓰고, (, ), {, }, [[, ]] 하위 명령이 LISP에 맞게 동작합니다.
-r [File] vi나 시스템이 비정상으로 끝난 뒤 파일을 복구합니다. File을 지정하지 않으면 저장된 파일 목록을 모두 보여 줍니다.
-R readonly 옵션을 켜서 파일을 덮어쓰지 못하게 합니다.
-t Tag Tag가 든 파일을 편집하며 그 정의 위치로 갑니다. 먼저 ctags 명령으로 함수 이름과 위치의 데이터베이스를 만들어야 합니다.
-v 자세한(verbose) 모드로 시작합니다.
-w Number 기본 창 크기를 Number로 정합니다. 느린 회선에서 쓸 때 좋습니다.
-y Number 최대 줄 수 1,048,560을 1024보다 큰 값으로 바꿉니다. vi가 버퍼를 다루는 데 줄을 더 쓰므로 필요한 줄 수의 두 배를 지정합니다.
+[Subcommand] 편집을 시작하기 전에 ex 하위 명령을 실행합니다. Subcommand를 지정하지 않으면 파일의 첫 줄에 커서를 둡니다(원문 그대로이며, 보통의 vi는 마지막 줄로 갑니다). -c와 함께 쓸 수 없습니다.
영어 원문
  • -cSubcommand — Carries out the ex editor subcommand before viewing with vi begins. The cursor moves to the line affected by the last subcommand to be carried out. When a null operand is entered, as in -c' ', the vi editor places the cursor on the first line of the file. The -c flag is incompatible with the + flag. Do not specify both flags at the same time.
  • -l — Enters the vi editor in LISP mode. In this mode, the vi editor creates indents appropriate for LISP code, and the (, ), {, }, [[, and ]] subcommands are modified to act appropriately for LISP.
  • -r[File] — Recovers a file after a vi editor or system malfunction. If you do not specify the File variable, the vi editor displays a list of all saved files.
  • -R — Sets the readonly option to protect the file against overwriting.
  • -tTag — Edits the file containing the Tag variable and positions the vi editor at its definition. To use this flag, you must first create a database of function names and their locations using the ctags command.
  • -v — Enters the vi editor in the verbose mode.
  • -wNumber — Sets the default window size to the value specified by the Number variable. This flag is useful when you use the vi editor over a low-speed line.
  • -yNumber — Overrides the maximum line setting of 1,048,560 with any value greater than 1024. You should request twice the number of lines that you require because the vi editor uses the extra lines for buffer manipulation.
  • +[Subcommand] — Carries out the ex editor subcommand before editing begins. If you do not specify the Subcommand variable, the cursor is placed on the first line of the file. This + flag is incompatible with the -c flag. Do not specify both flags at the same time.

하위 명령의 일반 구문

하위 명령은 다음 일반 구문으로 입력합니다. 대괄호는 선택 항목입니다.

text
[Named_Buffer] [Operator] [Number] Object
항목 뜻
[Named_Buffer] 글을 잠시 저장하는 곳입니다.
[Operator] 하위 명령이나 동작, 곧 vi에게 시키는 일입니다.
[Number] 동작의 범위나 줄 주소를 정수로 지정합니다.
Object 동작할 대상입니다. 글 객체(문자, 단어, 문장, 문단, 절, 문자열)나 글 위치(줄, 현재 줄의 위치, 화면 위치)입니다.

하위 명령 앞의 숫자

많은 하위 명령 앞에 숫자를 붙일 수 있으며, vi는 다음 중 하나로 해석합니다.

뜻 예
Number번 줄로 가기 5G, 10Z
Number번 열로 가기 25 뒤에 세로 막대
Number줄만큼 위아래로 스크롤 10Ctrl-U, 10Ctrl-D
영어 원문

Use the following general syntax to enter subcommands:

[Named_Buffer] [Operator] [Number] Object

Tip: Square brackets indicate optional items.

  • [Named_Buffer] — Specifies a temporary text storage area.
  • [Operator] — Specifies the subcommand or action; instructs the vi editor.
  • [Number] — Specifies either the extent of the action or a line address as a whole number.
  • Object — Specifies what to act on, such as a text object (a character, word, sentence, paragraph, section, character string) or a text position (a line, position in the current line, screen position).
  • Counts before Subcommands

You can put a number in front of many subcommands. The vi editor interprets this number in one of the following ways:

  • Go to the line specified by the Number parameter:
5G
10Z
  • Go to the column specified by the Number parameter:
25|
  • Scroll the number of lines up or down specified by the Number parameter:
10Ctrl-U
10Ctrl-D

하위 명령의 종류

하위 명령으로 다음 일을 합니다. 하위 명령은 모두 명령 모드에서 입력하며(입력 모드용은 따로 표시), 끝나지 않은 하위 명령은 Esc로 취소합니다.

  • 커서 옮기기
  • 글 편집
  • 파일 다루기
  • 그 밖의 동작
영어 원문

Use the subcommands to perform these kinds of actions:

  • Moving the cursor

  • Editing text

  • Manipulating files

  • Other actions

커서 옮기기

줄 안에서 옮기기

하위 명령 동작
왼쪽 화살표, h, Ctrl-H 한 문자 왼쪽
아래 화살표, j, Ctrl-J, Ctrl-N 한 줄 아래(같은 열)
위 화살표, k, Ctrl-P 한 줄 위(같은 열)
오른쪽 화살표, l 한 문자 오른쪽

문자 위치로 옮기기

하위 명령 동작
^ 공백이 아닌 첫 문자
0 줄의 처음
$ 줄의 끝
fx 다음 x 문자
Fx 앞의 x 문자
tx 다음 x 문자의 한 열 앞
Tx 앞의 x 문자의 한 열 뒤
; 마지막 f, F, t, T를 되풀이
, 마지막 f, F, t, T를 반대 방향으로 되풀이
Number 뒤 세로 막대 지정한 열

단어로 옮기기

하위 명령 동작
w 다음 작은 단어
b 앞의 작은 단어
e 다음 작은 단어의 끝
W 다음 큰 단어
B 앞의 큰 단어
E 다음 큰 단어의 끝

줄 위치로 옮기기

하위 명령 동작
H 화면의 맨 위 줄
L 화면의 마지막 줄
M 화면의 가운데 줄
+ 다음 줄의 공백이 아닌 첫 문자
- 앞 줄의 공백이 아닌 첫 문자
Enter 다음 줄의 공백이 아닌 첫 문자

문장, 문단, 절로 옮기기

하위 명령 동작
( 앞 문장의 처음(LISP 모드면 앞 s-식)
) 다음 문장의 처음(LISP 모드면 다음 s-식)
{ 앞 문단의 처음(LISP 모드면 다음 목록)
} 다음 문단의 처음(C 모드면 다음 절, LISP 모드면 다음 목록)
]] 다음 절(LISP 모드면 함수)
[[ 앞 절(LISP 모드면 함수)

화면을 다시 그려 옮기기

하위 명령 동작
z 현재 줄을 화면 맨 위에 두고 다시 그림
z- 현재 줄을 화면 맨 아래에 두고 다시 그림
z. 현재 줄을 화면 가운데에 두고 다시 그림
/Pattern/z- Pattern이 든 줄을 맨 아래에 두고 다시 그림

쪽 넘기기와 스크롤

하위 명령 동작
Ctrl-U 반 화면 위로
Ctrl-D 반 화면 아래로
Ctrl-F 한 화면 앞으로
Ctrl-B 한 화면 뒤로
Ctrl-E 창을 한 줄 아래로
Ctrl-Y 창을 한 줄 위로
z+ 쪽 위로(원문 그대로)
z^ 쪽 아래로(원문 그대로)

패턴 찾기

하위 명령 동작
[Number]G Number번 줄로 갑니다. Number가 없으면 마지막 줄
/Pattern Pattern이 든 다음 줄
?Pattern Pattern이 든 앞 줄
n 마지막 검색을 같은 방향으로 되풀이
N 마지막 검색을 반대 방향으로 되풀이
/Pattern/+Number Pattern과 맞는 줄에서 Number줄 뒤
?Pattern?-Number Pattern과 맞는 줄에서 Number줄 앞
% 커서 위치의 괄호나 중괄호와 짝이 되는 것
영어 원문

Use subcommands to move the cursor within a file in these ways:

  • Moving within a line

  • Moving within a line by character position

  • Moving to words

  • Moving by line position

  • Moving to sentences, paragraphs, or sections

  • Moving by redrawing the screen

  • Paging and scrolling

  • Searching for patterns

  • Marking a specific location in a file and returning

Moving within a Line

Enter the following subcommands in command mode. You can cancel an incomplete command by pressing the Esc key. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • Left Arrow or h or Ctrl-H — Moves the cursor one character to the left.
  • Down Arrow or j or Ctrl-J or Ctrl-N — Moves the cursor down one line (it remains in the same column).
  • Up Arrow or k or Ctrl-P — Moves the cursor up one line (it remains in the same column).
  • Right Arrow or l — Moves the cursor one character to the right.
  • Moving within a Line by Character Position

Enter the following subcommands in command mode. You can cancel an incomplete command by pressing the Esc key. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • ^ — Moves the cursor to the first nonblank character.
  • 0 — Moves the cursor to the beginning of the line.
  • $ — Moves the cursor to the end of the line.
  • fx — Moves the cursor to the next x character.
  • Fx — Moves the cursor to the last x character.
  • tx — Moves the cursor to one column before the next x character.
  • Tx — Moves the cursor to one column after the last x character.
  • ; — Repeats the last f, F, t, or T subcommand.
  • , — Repeats the last f, F, t, or T subcommand in the opposite direction.
  • Number| — Moves the cursor to the specified column.
  • Moving to Words

Enter the following subcommands in command mode. For more information about the format of vi subcommands, see vi General Subcommand Syntax.

  • w — Moves the cursor to the next small word.
  • b — Moves the cursor to the previous small word.
  • e — Moves the cursor to the next end of a small word.
  • W — Moves the cursor to the next big word.
  • B — Moves the cursor to the previous big word.
  • E — Moves the cursor to the next end of a big word.
  • Moving by Line Position

Enter the following subcommands in command mode. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • H — Moves the cursor to the top line on the screen.
  • L — Moves the cursor to the last line on the screen.
  • M — Moves the cursor to the middle line on the screen.
  • + — Moves the cursor to the next line at its first nonblank character.
  • - — Moves the cursor to the previous line at its first nonblank character.
  • Enter — Moves the cursor to the next line at its first nonblank character.
  • Moving to Sentences, Paragraphs, or Sections

Enter the following subcommands in command mode. You can cancel an incomplete subcommand by pressing the Esc key. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • ( — Places the cursor at the beginning of the previous sentence, or the previous s-expression if you are in LISP mode.
  • ) — Places the cursor at the beginning of the next sentence, or the next s-expression if you are in LISP mode.
  • { — Places the cursor at the beginning of the previous paragraph, or at the next list if you are in LISP mode.
  • } — Places the cursor at the beginning of the next paragraph, at the next section if you are in C mode, or at the next list if you are in LISP mode.
  • ]] — Places the cursor at the next section, or function if you are in LISP mode.
  • [[ — Places the cursor at the previous section, or function if you are in LISP mode.
  • Moving by Redrawing the Screen

Enter the following subcommands in command mode. You can cancel an incomplete subcommand by pressing the Esc key. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • z — Redraws the screen with the current line at the top of the screen.
  • z- — Redraws the screen with the current line at the bottom of the screen.
    1. — Redraws the screen with the current line at the center of the screen.
  • /Pattern/z- — Redraws the screen with the line containing the character string, specified by the Pattern parameter, at the bottom.
  • Paging and Scrolling

Enter the following subcommands in command mode. You can cancel an incomplete subcommand by pressing the Esc key. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • Ctrl-U — Scrolls up one-half screen.
  • Ctrl-D — Scrolls down one-half screen.
  • Ctrl-F — Scrolls forward one screen.
  • Ctrl-B — Scrolls backward one screen.
  • Ctrl-E — Scrolls the window down one line.
  • Ctrl-Y — Scrolls the window up one line.
  • z+ — Pages up.
  • z^ — Pages down.
  • Searching for Patterns

Enter the following subcommands in command mode. You can cancel an incomplete subcommand by pressing the Esc key. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • [Number]G — Places the cursor at the line number specified by the Number parameter or at the last line if the Number parameter is not specified.
  • /Pattern — Places the cursor at the next line containing the character string specified by the Pattern parameter.
  • ?Pattern — Places the cursor at the next previous line containing the character string specified by the Pattern parameter.
  • n — Repeats the last search for the text specified by the Pattern parameter in the same direction.
  • N — Repeats the last search for the text specified by the Pattern parameter in the opposite direction.
  • /Pattern/+Number — Places the cursor the specified number of lines after the line matching the character string specified by the Pattern parameter.
  • ?Pattern?-Number — Places the cursor the specified number of lines before the line matching the character string specified by the Pattern parameter.
  • % — Finds the parenthesis or brace that matches the one at current cursor position.

글 편집

위치를 표시하고 돌아가기

하위 명령 동작
백쿼트 기호 두 번 앞서 있던 위치로
''(작은따옴표 두 개) 앞서 있던 위치가 든 줄의 처음으로
mx 현재 위치에 x라는 표시를 함
백쿼트 기호 다음 x x 표시가 있는 위치로
'x x 표시가 든 줄의 처음으로

글 더하기(입력 모드)

다음 하위 명령은 입력 모드로 바꿉니다. Esc를 누르면 입력 모드가 끝납니다.

하위 명령 동작
aText 커서 뒤에 넣음
AText 줄 끝에 더함
iText 커서 앞에 넣음
IText 줄의 공백이 아닌 첫 문자 앞에 넣음
o 현재 줄 아래에 빈 줄을 더함
O 현재 줄 위에 빈 줄을 더함

입력 모드에서 글 고치기

다음은 입력 모드에서만 쓰며, 명령 모드에서는 뜻이 다릅니다.

키 동작
Ctrl-D 앞의 자동 들여쓰기 위치로 돌아감
^ Ctrl-D 이 줄만 자동 들여쓰기를 끝냄
0 Ctrl-D 왼쪽 여백으로 돌아감
Esc 넣기를 끝내고 명령 상태로 돌아감
Ctrl-H 마지막 문자를 지움
Ctrl-Q xon이 꺼져 있으면 아무 문자나 입력
Ctrl-V 아무 문자나 입력
Ctrl-W 마지막 작은 단어를 지움
\ 지우기·줄 지우기 문자를 글자로 입력
Ctrl-? 넣기나 Ctrl-D를 중단하고 끝냄

명령 모드에서 글 고치기

하위 명령 동작
C 줄의 나머지를 바꿈(c$와 같음)
cc 줄을 바꿈
cw 단어를 바꿈
cwText 단어를 Text로 바꿈
D 줄의 나머지를 지움(d$와 같음)
dd 줄을 지움
dw 단어를 지움
J 줄을 이음
rx 현재 문자를 x로 바꿈
RText Text로 덮어씀
s 문자를 바꿈(cl과 같음)
S 줄을 바꿈(cc와 같음)
u 앞의 변경을 되돌림
x 커서의 문자를 지움
X 커서 앞의 문자를 지움(dh와 같음)
<< 한 줄을 왼쪽으로 옮김
<L 커서부터 화면 끝까지의 줄을 왼쪽으로 옮김
>> 한 줄을 오른쪽으로 옮김
>L 커서부터 화면 끝까지의 줄을 오른쪽으로 옮김
~ 커서의 글자를 대소문자 반대로 바꿈
! LISP용으로 들여 씀

복사와 이동

하위 명령 동작
p 되돌리기 버퍼의 글을 커서 뒤에 넣음
P 되돌리기 버퍼의 글을 커서 앞에 넣음
"xp x 버퍼의 글을 넣음
"xd 글을 지워 x 버퍼에 넣음
y 뒤에 오는 객체(예: 단어는 w)를 되돌리기 버퍼에 넣음
"xy 뒤에 오는 객체를 x 버퍼에 넣음(x는 아무 글자)
Y 줄을 되돌리기 버퍼에 넣음

되돌리기와 되풀이

하위 명령 동작
u 마지막 변경을 되돌립니다. 되돌린 뒤 커서는 바뀐 현재 줄의 공백이 아닌 첫 문자로 갑니다.
U 마지막 변경 뒤 커서가 줄을 떠나지 않았으면 현재 줄을 되살립니다.
. 마지막 변경을 되풀이하거나 "np의 번호를 늘립니다. 되돌리기도 되풀이하므로, 되돌린 뒤에는 되돌리기를 되풀이합니다. 매크로에는 쓰지 않고, 매크로 되풀이는 @@를 씁니다.
"np n번째 전에 지운 줄 전체나 줄 묶음을 되찾습니다.
영어 원문

The subcommands for editing enable you to perform the following tasks:

  • Marking a specific location in a file and returning

  • Adding text to a file

  • Changing text while in input mode

  • Changing text from command mode

  • Copying and moving text

  • Restoring and repeating changes

Marking a Specific Location in a File and Returning

Enter the following subcommands in command mode. You can cancel an incomplete subcommand by pressing the Esc key. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • " — Moves the cursor to the previous location of the current line.
  • " — Moves the cursor to the beginning of the line containing the previous location of the current line.
  • mx — Marks the current position with the letter specified by the x parameter.
  • 'x — Moves the cursor to the mark specified by the x parameter.
  • 'x — Moves the cursor to the beginning of the line containing the mark specified by the x parameter.
  • Adding Text to a File (Text Input Mode)

Enter the following subcommands in command mode to change the vi editor into text input mode. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • aText — Inserts text specified by the Text parameter after the cursor. End text input mode by pressing the Esc key.
  • AText — Adds text specified by the Text parameter to the end of the line. End text input mode by pressing the Esc key.
  • iText — Inserts text specified by the Text parameter before the cursor. End text input mode by pressing the Esc key.
  • IText — Inserts text specified by the Text parameter before the first nonblank character in the line. End text input mode by pressing the Esc key.
  • o — Adds an empty line below the current line. End text input mode by pressing the Esc key.
  • O — Adds an empty line above the current line. End text input mode by pressing the Esc key.
  • Changing Text While in Input Mode

Use the following subcommands only while in text input mode. These commands have different meanings in command mode. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • Ctrl-D — Goes back to previous autoindent stop.
  • ^ Ctrl-D — Ends autoindent for this line only.
  • 0Ctrl-D — Moves cursor back to left margin.
  • Esc — Ends insertion and returns to command state.
  • Ctrl-H — Erases the last character.
  • Ctrl-Q — Enters any character if xon is disabled.
  • Ctrl-V — Enters any character.
  • Ctrl-W — Erases the last small word.
  • \ — Quotes the erase and kill characters.
  • Ctrl-? — Interrupts and ends insert or the Ctrl-D key sequence.
  • Changing Text from Command Mode

Use the following subcommands in command mode. An incomplete subcommand can be canceled by pressing the Esc key. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • C — Changes the rest of the line (same as c$).
  • cc — Changes a line.
  • cw — Changes a word.
  • cwText — Changes a word to the text specified by the Text parameter.
  • D — Deletes the rest of the line (same as d$).
  • dd — Deletes a line.
  • dw — Deletes a word.
  • J — Joins lines.
  • rx — Replaces the current character with the character specified by x.
  • RText — Overwrites characters with the text specified by the Text parameter.
  • s — Substitutes characters (same as cl).
  • S — Substitutes lines (same as cc).
  • u — Undoes the previous change.
  • x — Deletes a character at the cursor.
  • X — Deletes a character before the cursor (same as dh).
  • << — Shifts one line to the left.
  • <L — Shifts all lines from the cursor to the end of the screen to the left.
  • >> — Shifts one line to the right.
  • >L — Shifts all lines from the cursor to the end of the screen to the right.
  • ~ — Changes letter at the cursor to the opposite case.
  • ! — Indents for LISP.
  • Copying and Moving Text

Use the following subcommands in command mode. An incomplete subcommand can be canceled by pressing the Esc key. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • p — Puts back text from the undo buffer after the cursor.
  • P — Puts back text from the undo buffer before the cursor.
  • "xp — Puts back text from the x buffer.
  • "xd — Deletes text into the x buffer.
  • y — Places the object that follows (for example, w for word) into the undo buffer.
  • "xy — Places the object that follows into the x buffer, where x is any letter.
  • Y — Places the line in the undo buffer.
  • Restoring and Repeating Changes

Use the following subcommands in command mode. An incomplete subcommand can be canceled by pressing the Esc key. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • u — Undoes the last change. Tip: After an undo, the cursor moves to the first non-blank character on the updated current line.
  • U — Restores the current line if the cursor has not left the line since the last change.
  • . — Repeats the last change or increments the "np command. Note: 1. This subcommand will repeat the last change, including an undo. Therefore, after an undo, repeat performs an undo rather than repeat the last change. 2. This subcommand is not meant for use with a macro. Enter @@ (two at signs) to repeat a macro.
  • "n p — Retrieves the nth last delete of a complete line or block of lines.

파일 다루기

ex 편집기 안에서 쓸 때는 앞의 :(쌍점)를 입력하지 않아도 됩니다.

파일에 저장하기

하위 명령 동작
:w 편집 버퍼를 원래 파일에 씁니다.
:w File 편집 버퍼를 File에 씁니다.
:w! File 편집 버퍼로 File을 덮어씁니다.

다른 파일 편집하기

하위 명령 동작
:e File 지정한 파일을 편집합니다.
:e! 바뀐 것을 모두 버리고 현재 파일을 다시 편집합니다.
:e + File 지정한 파일을 끝에서부터 편집합니다.
:e + Number File 지정한 파일을 Number번 줄부터 편집합니다.
:e # 교대 파일을 편집합니다. 교대 파일은 보통 :e로 다른 파일을 열기 전의 파일이지만, 새 파일을 부를 때 현재 파일에 저장하지 않은 변경이 있으면 새 파일이 교대 파일이 됩니다. Ctrl-A와 같습니다.
:r File 파일을 현재 줄 아래에 새 줄로 읽어 넣습니다.
:r !Command 명령을 실행해 출력을 커서 아래에 새 줄로 넣습니다.
:ta Tag Tag가 든 파일을 태그 위치부터 편집합니다. 먼저 ctags로 데이터베이스를 만들어야 합니다.
Ctrl-] 현재 단어에 해당하는 태그가 든 파일을 태그 위치부터 편집합니다. Ctrl-T는 앞서 Ctrl-]를 실행한 위치로 돌아가며, Ctrl-]를 여러 번 했으면 Ctrl-T도 여러 번 써서 차례로 돌아갈 수 있습니다.
Ctrl-A 교대 파일을 편집합니다. :e #과 같습니다.

파일 목록 편집하기

하위 명령 동작
:n 명령줄에 준 목록의 다음 파일을 편집합니다.
:n Files 편집할 새 파일 목록을 지정합니다.

파일 정보 보기

하위 명령 동작
Ctrl-G 현재 파일 이름, 현재 줄 번호, 파일의 줄 수, 커서가 파일의 몇 퍼센트 지점에 있는지 보여 줍니다.
영어 원문

The subcommands for manipulating files allow you to do the tasks outlined in the following sections:

  • Saving changes to a file

  • Editing a second file

  • Editing a list of files

  • Finding file information

Saving Changes to a File

Use the following subcommands in command mode. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • :w — Writes the edit buffer contents to the original file. If you are using this subcommand within the ex editor, you do not need to type the : (colon).
  • :w File — Writes the edit buffer contents to the file specified by the File parameter. If you are using this subcommand within the ex editor, you do not need to type the : (colon).
  • :w! File — Overwrites the file specified by the File parameter with the edit buffer contents. If you are using this subcommand within the ex editor, you do not need to type the : (colon).
  • Editing a Second File

Enter the following subcommands in command mode. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • :e File — Edits the specified file. If you are using this subcommand from the ex editor, you do not need to type the : (colon).
  • :e! — Re-edits the current file and discards all changes.
  • :e + File — Edits the specified file starting at the end.
  • :e + Number File — Edits the specified file starting at the specified line number.
  • :e # — Edits the alternate file. The alternate file is usually the previous file name before accessing another file with a :e command. However, if changes are pending on the current file when a new file is called, the new file becomes the alternate file. This subcommand is the same as the Ctrl-A subcommand.
  • :r File — Reads the file into the editing buffer by adding new lines below the current line. If you are using this subcommand from the ex editor, you do not need to type the : (colon).
  • :r !Command — Runs the specified command and places its output into the file by adding new lines below the current cursor position.
  • :ta Tag — Edits a file containing the Tag tag starting at the location of the tag. To use this subcommand, you must first create a database of function names and their locations using the ctags command. If you are using this subcommand from the ex editor, you do not need to type the : (colon).
  • Ctrl-] — Edits a file containing the tag associated with the current word starting at the location of the tag. To use this subcommand, you must first create a database of function names and their locations using the ctags command. Ctrl-T edits a file at the editing position where the previous Ctrl-] subcommand was issued. If multiple Ctrl-] subcommands have been issued, then multiple Ctrl-T subcommands can be used to return to previous editing positions where Ctrl-] subcommands were issued.
  • Ctrl-A — Edits the alternate file. The alternate file is usually the previous current file name. However, if changes are pending on the current file when a new file is called, the new file becomes the alternate file. This subcommand is the same as the :e # subcommand.
  • Editing a List of Files

Enter the following subcommands in command mode. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • :n — Edits the next file in the list entered on the command line. If you are using this subcommand from the ex editor, a : (colon) is not needed.
  • :n Files — Specifies a new list of files to edit. If you are using this subcommand from the ex editor, a : (colon) is not needed.
  • Finding File Information

Enter the following subcommand in command mode. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • Ctrl-G — Shows the current file name, current line number, number of lines in the file, and percentage of the way through the file where the cursor is located.

그 밖의 동작

화면 조정

하위 명령 동작
Ctrl-L 화면을 지우고 다시 그립니다.
Ctrl-R 화면을 다시 그리고 @로 표시된 빈 줄을 없앱니다.
zNumber 창의 길이를 Number줄로 합니다.

셸 명령 실행

하위 명령 동작
:sh 셸에 들어가 명령을 여러 개 실행합니다. Ctrl-D로 vi에 돌아옵니다.
:!Command 명령을 실행하고 vi로 돌아옵니다. :! 뒤의 #(교대 파일), %(현재 파일), !(앞 명령)는 펼쳐지며, 펼치지 않으려면 \를 앞에 붙입니다.
:!! 마지막 :!Command를 되풀이합니다.
Number!!Command 명령을 실행해 Number줄(기본 1)을 그 출력으로 바꿉니다. 명령이 표준 입력을 받으면 그 줄들을 입력으로 줍니다.
!Object Command 명령을 실행해 Object를 그 출력으로 바꿉니다. 명령이 표준 입력을 받으면 그 객체를 입력으로 줍니다.

중단하고 끝내기

하위 명령 동작
Q ex 편집기의 명령 모드로 들어갑니다.
ZZ 바뀐 것을 저장하고 끝냅니다.
:q 끝냅니다. 편집 버퍼가 바뀌었으면 경고를 보여 주고 끝내지 않습니다.
:q! 편집 버퍼를 버리고 끝냅니다.
Esc 입력이나 끝나지 않은 하위 명령을 끝냅니다.
Ctrl-? 하위 명령을 중단합니다.
영어 원문

The vi editor provides the subcommands described in the following sections:

  • Adjusting the screen

  • Entering shell commands

  • Interrupting and ending the vi editor

Adjusting the Screen

Enter the following subcommands in command mode. An incomplete subcommand can be canceled by pressing the Esc key. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • Ctrl-L — Clears and redraws the screen.
  • Ctrl-R — Redraws the screen and eliminates blank lines marked with @ (at sign).
  • zNumber — Makes the window the specified number of lines long.
  • Entering Shell Commands

The following subcommands allow you to run a command within the vi editor. Enter these subcommands in command mode. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • :sh — Enters the shell to allow you to run more than one command. You can return to the vi editor by pressing the Ctrl-D key sequence. If you are using this subcommand within the ex editor, a : (colon) is not needed.
  • :!Command — Runs the specified command and then returns to the vi editor. If you are using this subcommand within the ex editor, a : (colon) is not needed. Tip: The # (alternate file), % (current file), and ! (previous command) special characters are expanded when following a :! subcommand. To prevent any of these characters from being expanded, use the \ (backslash).
  • :!! — Repeats the last :!Command subcommand.
  • Number!!Command — Runs the specified command and replaces the lines specified by Number with the output of the command. If a number is not specified, the default value is 1. If the command expects standard input, the specified lines are used as input.
  • !Object Command — Runs the specified command and replaces the object specified by the Object parameter with the output of the command. If the command expects standard input, the specified object is used as input.
  • Interrupting and Ending the vi Editor

Enter the following subcommands in command mode. If you need information about the format of vi subcommands, see vi General Subcommand Syntax.

  • Q — Enters the ex editor in command mode.
  • ZZ — Exits the vi editor, saving changes.
  • :q — Quits the vi editor. If you have changed the contents of the editing buffer, the vi editor displays a warning message and does not quit. If you are using this subcommand from the ex editor, a : (colon) is not needed.
  • :q! — Quits the vi editor, discarding the editing buffer. If you are using this subcommand from the ex editor, a : (colon) is not needed.
  • Esc — Ends text input or ends an incomplete subcommand.
  • Ctrl-? — Interrupts a subcommand.

종료 상태

값 뜻
0 잘 끝났습니다.
0보다 큼 오류가 났습니다.
영어 원문

The following exit values are returned:

  • 0 — Indicates successful completion.
  • >0 — Indicates an error occurred.

입력 파일

  • 입력 파일은 텍스트 파일이거나, NULL 문자가 없는 마지막 줄이 끝나지 않았다는 점만 빼면 텍스트 파일과 비슷한 파일이어야 합니다.
  • .exrc 파일은 ex 명령으로 된 텍스트 파일이어야 합니다.
  • $HOME/.vi_history 파일은 마지막 줄 모드의 명령 기록을 남기는, 자동으로 만들어지는 텍스트 파일입니다.
  • 기본으로 vi는 편집할 파일의 줄을 읽을 때 어떤 줄도 vi 명령으로 해석하지 않습니다(modeline 옵션 참고).

관련 명령어: ctags, ex, tvi

영어 원문

Input files must be text files or files that are similar to text files except for an incomplete last line that contains no null characters.

The .exrc files must be text files consisting of ex commands.

The $HOME/.vi_history file is an auto-generated text file that records the last line mode command history.

By default, the vi editor reads lines from the files to be edited without interpreting any of those lines as any form of vi editor command.

Related information:

  • ctags command
  • ex command

tvi command .profile file

리눅스(GNU)와 다른 점

리눅스의 vi는 대개 Vim이며, AIX의 vi는 원래의 vi(ex 기반)입니다.

항목 AIX 5.3·6.1 vi Vim
되돌리기 u는 한 단계, 다시 u를 누르면 되돌리기를 되돌림 여러 단계 되돌리기, Ctrl-R로 다시 실행
비주얼 모드 없음(v, V, Ctrl-V는 매핑용으로 비어 있음) 있음
문법 강조, 창 나누기, :s의 \v 등 없음 있음
설정 파일 EXINIT, $HOME/.exrc, 현재 디렉터리의 .exrc ~/.vimrc
한도 줄 1,048,560개, 편집 버퍼 2GB 메모리에 따름

AIX에서 화살표 키나 Backspace가 이상하게 동작하면 TERM 값과 :map 목록을 먼저 확인합니다.