Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.editors Subject: Re: Register Commands in Vi Message-ID: <3312@solo1.cs.vu.nl> Date: 20 Sep 89 19:09:47 GMT References: <518@dcdwest.UUCP> Organization: V.U. Informatica, Amsterdam, the Netherlands Lines: 45 benson@dcdwest.UUCP (Peter Benson) writes: \... I would like to \position the cursor at the front of a file name, as in the "s" \in system in \ \.so system \ \and have the command \ \:n system \ \be executed. [...] map v ma:!:^V^M :t.^V^Mkc`a:e!^V^[ea ^V^[D^V^V"zdd@z Explanation: ma = mark the current position with `a' :!:^V^M = this shell escape will force the buffer to be ^ written if it has been modified AND the option space `autowrite' is set; all further modifications due to the map are irrelevant and will be discarded (see `e!' below) the `:' command does nothing in sh and csh the ^M (return) needs to be escaped with ^V, else the map would be terminated :t.^V^M = this "ex" command will put a copy of the current line right below it (`yyp' seems to cause trouble) k = upward one line (back to the original line) c`a:e!^V^[ = change till the mark `a' just like ^M the escape ^[ needs to be escaped e = go to the end of the next word (our filename) a ^V^[ = append a space, to make sure there's something to delete (see `D') D = delete the rest of the line ^V^V"zdd = delete the current line into register `z' the `"' must be escaped upon the first READING of the map, since it is the "ex" comment character (NOTE: not necessary in some vi versions) @z = execute the contents of register `z': :e!file^J -- creat(2) shouldn't have been create(2): |Maarten Litmaath @ VU Amsterdam: it shouldn't have existed at all. |maart@cs.vu.nl, mcvax!botter!maart