sergio@ingres.com (Sergio Aponte) (09/21/90)
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? It would be nice to type "6B" and have the lines moved. Thanks -- ------------------------------------------------------------------------------- | Internet: sergio@squid.ingres.com Sergio L. Aponte, MTS @ Ingres Corp. | | UUCP : {sun,mtxinu,pyramid,pacbell,hoptoad,amdahl}!ingres!squid!sergio | -------------------------------------------------------------------------------
dattier@ddsw1.MCS.COM (David W. Tamkin) (09/23/90)
<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
sergio@ingres.com (Sergio Aponte) (09/25/90)
In article <1990Sep22.173733.28318@ddsw1.MCS.COM> dattier@ddsw1.MCS.COM (David W. Tamkin) writes: ><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? >| It would be nice to type "6B" and have the lines moved. > > >:map V "zddG"zp [again, that's a capital gee, not a numeral six] > > >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 I deleted some lines for brevity. I ended up with map Z "zddmzG"zp'z which also lets me get back to where I started from. That way, I can take a "chunk" of lines, move it to the end, and continue editing where I was. Thank you all for the e-mail. I got it all. PS: There was mention of using "zddG"zp'' and the '' was supposed to put me back. This gave me an error when I tried using it. What did I do wrong, if anybody knows? Sergio -- ------------------------------------------------------------------------------- | Internet: sergio@squid.ingres.com Sergio L. Aponte, MTS @ Ingres Corp. | | UUCP : {sun,mtxinu,pyramid,pacbell,hoptoad,amdahl}!ingres!squid!sergio | -------------------------------------------------------------------------------