Path: utzoo!attcan!uunet!bbs!ddsw1!dattier From: dattier@ddsw1.MCS.COM (David W. Tamkin) Newsgroups: comp.editors Subject: Re: VI : move current plus n lines to bottom Summary: yes, it can be done Message-ID: <1990Sep22.173733.28318@ddsw1.MCS.COM> Date: 22 Sep 90 17:37:33 GMT References: <1990Sep20.231510.4199@ingres.Ingres.COM> Reply-To: dattier@ddsw1.MCS.COM (David W. Tamkin) Organization: Contributor Account at ddsw1, Wheeling, Illinois Lines: 38 <1990Sep20.231510.4199@ingres.Ingres.COM> by sergio@squid.Ingres.COM (Sergio Aponte): | In VI, I find myself in the need to move the current+n lines | to the bottom of the file. I dont know much about macros. Can | one be writen that will move the current plus n lines to the | bottom of the current file? My first instinct was (current+n meaning a total of n+1 lines) to recommend :.,+n m$ [to move n+1 lines to the end]. But Mr. Aponte continued: | It would be nice to type "6B" and have the lines moved. Ah; that requires a different approach if you want to define a macro with the number in front. First, you'll need to use the total number of lines instead of the number of lines following the current line: "6" will mean the current line plus five more, totaling six, rather than the current line plus six more. You'll probably want to save B for its original function, but V is next to it on the keyboard and unassigned, so let's use V. :map V ddGp [that's a capital gee, not a numeral six] (from the command line or in your .exrc) will do it. You can use a named register if you want, like this: :map V "zddG"zp [again, that's a capital gee, not a numeral six] but you'll still clobber the undo buffer anyway. (Yes, specifying the number before selecting a register does work.) The only way to get around clobber- ing the undo buffer is to use the ex syntax (:.,+n m$ where n is the number of additional lines past the current line). However, if you make a macro of it you'll have to hard-code the number of lines to move; I know of no way to put that onto a macro that will accept a number as a prepended parameter. You could set up nine or ten mappings (from V0 or V1 through V9), each with a hard-coded number, but that gets to be more work than it might be worth. David Tamkin Box 7002 Des Plaines IL 60018-7002 708 518 6769 312 693 0591 MCI Mail: 426-1818 GEnie: D.W.TAMKIN CIS: 73720,1570 dattier@ddsw1.mcs.com