#print Misc. Useful Features - Advanced Insert Mode There are a few things which you can do in insert mode which we didn't talk about before. For example, you probably noticed that you can use the backspace key to backup. You can also use your 'kill' character (usually @, but often reset to ^X or ^U) to back up over everything you've inserted on that line. If for some reason you need to insert a control character into your file, just prefix a ^V to it. For example, typing '^V^H' will insert a backspace character (^H), instead of erasing the preceeding character. Lastly, you can use ^W to backspace over a whole word at once. Another commonly-useful insert feature is auto-indent mode. This feature makes vi automatically indent each new line the same amount as the previous line. This is highly convenient when typing programs and indented paragraphs and tables. To turn this feature on, type ':set autoindent' or ':set ai'. Once this is on, if you want to move backwards beyond the indent, you'll need to use the ^D command, standing for 'detab'. This is different from the ^D command which scrolls in that this one is only useful while you're in insert mode. Type 'ready' to try out autoindenting and the other insert-mode features. #user #create AdvInsert A summary of the commands usable with insert mode: backspace = Just that kill character = Backspace over whole line (usually @ or ^X or ^U) ^V = To insert a control character ^W = Backspace over the last word :set autoindent or = Turn on autoindenting :set ai :set noautoindent or = Turn off autoindenting :set noai ^D ^T = Move backwards or forwards one shiftwidth Except for the :set commands, all of these only work while you're in insert mode. Experiment with them, especially the ^D and ^T commands with autoindenting turned on. -------------------------------------------------------------------------- # cat /usr/share/learn/vi/longtext >> AdvInsert vi AdvInsert #next 6.2 10