Полезная информация

UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 31.12 Text-Input Mode Cursor Motion with No Arrow Keys Chapter 31
Creating Custom Commands in vi
Next: 31.14 Don't Lose Important Functions with vi Maps: Use noremap
 

31.13 Making Cursor Keys Work in vi Text-input Mode

Here is my .exrc file, which I customized for a VT100 terminal. It is set up for C and nroff -me macros. [Strings like ^[OD are set by the cursor keys (41.12) on VT100-type terminals. Make the ^[ by typing [CTRL-v] [ESC]. Many vi versions make this easier; they understand map #1 (31.2) to mean "map function key F1."-JP ]













troff 

set ai redraw sm wm=1
set tabstop=4
set shiftwidth=4
map! {} {^M}^[O^I     Great for auto indenting { } pairs
map! ^[OD ^[ha        Cursor left while inputting
map! ^[OA ^[ka        Cursor up while inputting
map! ^[OB ^[ja        Cursor down while inputting
map! ^[OC ^[la        Cursor right while inputting
map  ^[OP A           Mapped F1 to append to end of line
map! ^[OP ^[A         Text-input mode of the above
map  ^[OQ 0i          Mapped F2 to insert before line
map! ^[OQ ^[0i        Text-input mode of the above
map! ``  \*(lq        troff left quote
map! ''  \*(rq        troff right quote

I can use the cursor keys while inputting text. This is handy because I can back up and add text without pressing ESC. [Though you may not be able to (31.3) undo your previous change with the u command. -JP ]

Also, I have defined [F1] to append at the end of the line. This is useful because it doesn't matter what mode you are in, it always puts you in text-input mode.

At one time, I mapped the entire numeric keypad to emulate the EDT editor.

- BB in net.unix on Usenet, 9 October 1986


Previous: 31.12 Text-Input Mode Cursor Motion with No Arrow Keys UNIX Power ToolsNext: 31.14 Don't Lose Important Functions with vi Maps: Use noremap
31.12 Text-Input Mode Cursor Motion with No Arrow Keys Book Index31.14 Don't Lose Important Functions with vi Maps: Use noremap

The UNIX CD Bookshelf NavigationThe UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System