From: Anahata <Anah...@freereed.demon.co.uk> Subject: Learning VI Date: 1997/01/28 Message-ID: <jmQ7$JAFac7yEwun@freereed.demon.co.uk>#1/1 X-Deja-AN: 212695632 distribution: world x-nntp-posting-host: freereed.demon.co.uk organization: First Equity mime-version: 1.0 newsgroups: uk.comp.os.linux I've installed Linux, and the first thing I seem to need to be able to do is edit text files. I'm familiar with ed, but under the impression that vi (or its improved successor vim) is the editor of choice, notwithstanding the existence of some other "wordstar-like" editors for DOS weenies like myself. So, how do I go about learning to use vi/vim? My slackware96 installation has a big reference manual for vim, but one of the first things that says is that it assumes prior knowledge of vi. The man pages tell you how to invoke it and the command line switches, but where's the idiot's self-help guide to using the editor once you're in it? It took a long time before I managed even to get out of it without deliberately rebooting. Alternatively, at the risk of starting a religious war, are there good alternatives for a simple text editor? Anahata anah...@freereed.demon.co.uk + http://www.freereed.demon.co.uk/ anah...@locust.co.uk email to mobile phone 8 line messages max 0171 638 5577 (W) 0171 229 6076 (H) 0976 263827 (mobile)
From: Mike Jagdis <m...@roan.co.uk> Subject: Re: Learning VI Date: 1997/01/29 Message-ID: <E4rvyC.EFK@roan.co.uk>#1/1 X-Deja-AN: 213216914 x-mail2news-path: relay-7.mail.demon.net!relay-5.mail.demon.net! whthom.demon.co.uk!toaster.roan.co.uk references: <jmQ7$JAFac7yEwun@freereed.demon.co.uk> x-mail2news-user: n...@toaster.roan.co.uk organization: Roan Technology Ltd. x-comment-to: Anahata <Anah...@freereed.demon.co.uk> newsgroups: uk.comp.os.linux Anahata said >So, how do I go about learning to use vi/vim? My slackware96 >installation has a big reference manual for vim, but one of the first >things that says is that it assumes prior knowledge of vi. First copy some miscellaneous text file to /tmp/zzz and "vi /tmp/zzz". Now, vi (and clones) is modal. Initially you are in "move about" mode and various keys move the cursor around. h, j, k and l move left, down, up nd right respectively - as they do in the classic ascii dungeon games like rogue and {net}hack. (Some vi clones like vim let you use cursor keys as well). w moves forward a word, b moves back a word. You can also delete the character you are on with x and d followed by something else deletes other objects - dw deletes the word you are on and dd deletes the line. The other important mode is insert mode. Type an i and you start inserting _before_ the character you are on. Type an a and you start inserting _after_. A capital A starts adding at the end of the line. In insert mode what you type goes into the file. To get out of insert mode - and back to move - type ESC or whatever your interrupt key is today (probably ^C or DEL). The last mode you _need_ is colon commands. Type a : in move mode and the cursor drops down the bottom and lets you type in a single line command - which can be hideously complex :-). :w saves the current file. :q exits. :q! exits discarding any changes (with no ! you wll be told off). :wq saves and exits (as does ZZ in move mode). With that you should have enough of a framework to figure out how to experiment with other stuff - and should be able to do 90% of your work. Vi was feature bloated long before MS decided to market the concept :-). Mike -- .----------------------------------------------------------------------. | Mike Jagdis | Internet: mailto:m...@roan.co.uk | | Roan Technology Ltd. | | | 54A Peach Street, Wokingham | Telephone: +44 118 989 0403 |
From: p...@sable.soc.staffs.ac.uk (Phil Cornes) Subject: Re: Learning VI Date: 1997/02/07 Message-ID: <5devls$a9g@bs33n.staffs.ac.uk>#1/1 X-Deja-AN: 215192375 distribution: world references: <jmQ7$JAFac7yEwun@freereed.demon.co.uk> organization: Staffordshire University newsgroups: uk.comp.os.linux Anahata (Anah...@freereed.demon.co.uk) wrote: : I've installed Linux, and the first thing I seem to need to be able to : do is edit text files. [snip] : So, how do I go about learning to use vi/vim? [snip] : Anahata : anah...@freereed.demon.co.uk + http://www.freereed.demon.co.uk/ : anah...@locust.co.uk email to mobile phone 8 line messages max : 0171 638 5577 (W) 0171 229 6076 (H) 0976 263827 (mobile) Hi The only real answer to that question is practice - but it's well worth the trouble... Assuming you want to do that here is a simple cheat sheet you might find helpful with most of the vi commands on that you will need to get started. It's formatted to fit on a single printer sheet if you want to cut it out and print it. Phil Cornes -----------* ============================================================================= EDITING WITH VI enter vi exit vi ~~~~~~~~~~~~~~~ | ^ | vi filename | wq v | +----------+ <ctrl>-[ +----------+ : +----------+ | insert |--------------->| edit |--------------->| command | | mode |<---------------| mode |<---------------| mode | +----------+ i, a, o, etc. +----------+ <cr> +----------+ EDIT MODE - to move the cursor round the screen and delete text ~~~~~~~~~ <ctrl>-f move cursor forward one page <ctrl>-b move cursor backward one page j move cursor down one line k move cursor up one line l move cursor right one character h move cursor left one character 0 (zero) move cursor to start of line $ move cursor to end of line <n>x delete <n> character (default <n> is 1) <n>dd delete <n> lines from cursor into cut-buffer d0 (d zero) delete to start of line d$ delete to end of line r<c> replace current cursor character with <c> % find bracket to match current cursor character p (lower) paste cut-buffer after current line P (upper) paste cut-buffer before current line u undo the effect of the last command . (dot) repeat the last command : switch from edit mode to command mode INSERT MODE - allows text to be inserted into file/document ~~~~~~~~~~~ i insert text before current cursor I insert text at start of current line a insert text after current cursor A insert text at end of current line o open a gap on the next line and enter insert O open a gap on previous line and enter insert <n>s delete <n> characters and enter insert mode <ctrl>-[ exit insert mode back to edit mode COMMAND MODE - entered with colon from edit mode ~~~~~~~~~~~~ <number> goto given line number in text/document /<text>/ search forward from cursor for first <text> s/<a>/<b>/ replace first <a> with <b> on current line s/<a>/<b>/g replace every <a> with <b> on current line g/<a>/s//<b>/g replace every <a> with <b> in whole file w <file> write text/document to specified <file> !<cmd> run the UNIX command <cmd> from within vi q! quit vi without saving any edits made wq combined write file and quit editor command =============================================================================
From: Anahata <Anah...@freereed.demon.co.uk> Subject: Re: Learning VI Date: 1997/02/07 Message-ID: <4rgt8BATDx+yEw0u@freereed.demon.co.uk>#1/1 X-Deja-AN: 215057825 distribution: world x-nntp-posting-host: freereed.demon.co.uk references: <jmQ7$JAFac7yEwun@freereed.demon.co.uk> organization: First Equity mime-version: 1.0 newsgroups: uk.comp.os.linux Phil Cornes <p...@sable.soc.staffs.ac.uk> writes >Assuming you want to do that here is a simple cheat sheet you might >find helpful with most of the vi commands on that you will need to >get started. It's formatted to fit on a single printer sheet if you >want to cut it out and print it. Gee thanks... did you make that yourself? Printed out and kept. Anahata anah...@freereed.demon.co.uk + http://www.freereed.demon.co.uk/ anah...@locust.co.uk email to mobile phone 8 line messages max 0171 638 5577 (W) 0171 229 6076 (H) 0976 263827 (mobile)