玄箱の vi は出所が分からないので vi クローンの一種のelvisをインストールする。
https://elvis.the-little-red-haired-girl.org/
tar zxf elvis-2.2_0.tar.gz cd elvis-2.2_0/ ./configure --bindir=/usr/bin --datadir=/usr/lib/elvis --without-x make su make install
# cd /usr/bin # ls -lt elvis -rwxr-xr-x 1 root root 574180 Feb 1 23:18 elvis
strip -p elvis # ls -lt elvis -rwxr-xr-x 1 root root 530308 Feb 1 23:18 elvis
玄箱の vi と入れ替える。
cd /bin mv vi vi.kuro ln -s /usr/bin/elvis vi
マニュアルは/usr/share/elvis/doc/にインストールされる。
elvis /usr/share/elvis/doc/elvis.man
マニュアルページもelvisで読むことができる。
NAME
elvis - a clone of the ex/vi text editor
SYNOPSIS
elvis [-V...] [-a] [-r] [-e] [-i] [-s|-] [-b] [-R] [-S|-SS] [-f session] [-o
logfile] [-G gui] [-c command|+command] [-t tag] [-w scroll] [-B blksize]
[file]...
VERSION
Elvis 2.2_0_0
DESCRIPTION
Elvis is a text editor. It is intended to be a modern replacement for the
classic ex/vi editor of UNIX fame. Elvis supports many new features,
including multiple edit buffers, multiple windows, multiple user interfaces
(including an X11 interface), and a variety of display modes.
viの特徴は入力モードとコマンドモードがあることです。 この2つのモードがあることが、Windowsのメモ帳などのエディタになれたユーザに とって vi が使いにくい原因となっています。
しかし、UNIX上で古くから使われており、動作が軽く機能も豊富であることから 多くの「vi使い」がいるようです。すべてのUNIX系OSでは最初から使えるように なっており、何か事故が起きてコンソールから作業しなければならない場合には 必須のエディタです。UNIX系のOSのシステム管理者は避けて通れないコマンドです。 ファイルの内容を表示する「cat」「less」「more」よりコマンド名が短く起動も 速いため、ファイルを表示するだけでも vi を使ったりします。
vi には多くの種類があり、それぞれオリジナルの vi に色々な拡張を行っています。
vi ファイル名
ZZ
| h or ← | カーソルを左に移動 |
| j or ↓ | カーソルを左に移動 |
| k or ↑ | カーソルを上に移動 |
| l or → | カーソルを右に移動 |
| G | 最終行に移動 |
| 1G | 先頭行に移動 |
| xxxG | xxxで指定した行番号に移動 |
| /xxx | xxxに入力した文字列を前方検索 |
| ?xxx | xxxに入力した文字列を後方検索 |
| i | その位置で編集モードに移行 |
| a | 行末で編集モードに移行 |
| o | カーソル直後で改行 |
| O | カーソル直前で改行 |
| J | カーソル行と次の行を連結 |
| r | 次に入力する1文字と置き換え |
| R | 以降に入力する文字と置き換え(上書き編集モード) |
| x | カーソル位置の1文字消去 |
| X | カーソル直前の1文字消去 |
| dd | カーソル位置の1行を削除 |
| p | カットバッファをカーソル以降に挿入 |
| P | カットバッファをカーソル直前に挿入 |
| yy | カーソル行をカットバッファにコピー |
| u | アンドゥ(元に戻す) |
| ZZ | 上書き保存して終了 |
| :q! | 保存しないで終了 |
| :w ファイル名 | ファイル名を付けて保存 |
| :r ファイル名 | ファイルを読み込む |
| :! コマンド | コマンドを実行して表示 |
| :r! コマンド | コマンドの実行結果を読み込む |