Vim Tips Wiki
No edit summary
 
(Remove html character entities)
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{review}}
 
{{review}}
  +
{{TipImported
{{Tip
 
 
|id=1435
 
|id=1435
  +
|previous=1434
|title=use recording to easily add function skeletons from prototypes
 
  +
|next=1436
|created=December 8, 2006 14:36
+
|created=December 8, 2006
 
|complexity=intermediate
 
|complexity=intermediate
 
|author=Peter Jenkins
 
|author=Peter Jenkins
 
|version=5.7
 
|version=5.7
 
|rating=143/39
 
|rating=143/39
  +
|category1=
|text=
 
  +
|category2=
Figuring this out showed me what vim is capable of.
 
 
}}
  +
<pre>
 
:let @u = "<<<<<<<<<<dd?int main(^MkO^[pY/main(^M/{^M%o^M^[p^[kdd$s^M{^M^M^M}^[kki^I"
  +
</pre>
   
 
For ^M, ^I, ^[, you need to do ^v first. ^I may show up as a space. you might have to do ^v <Tab>
   
 
This will take a function prototype wherever it is in your C code, make it flush left (if it's less than 5 or so tabs in), cut it and paste it one line above main, then copy it again to right under main, remove the semicolon, add paired braces, move in between them, tab over and put you in insert mode.
   
 
I'm not using recording here, but that's how i generated the register. You can edit the recorded register as described in [[VimTip144]].
:let @u = "&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;dd?int main(^MkO^[pY/main(^M/{^M%o^M^[p^[kdd$s^M{^M^M^M}^[kki^I"
 
 
 
 
note, for ^M, ^I, ^[, you need to do ^v first. ^I may show up as a space. you might have to do ^v &lt;tab&gt;
 
 
 
 
this will take a function prototype wherever it is in your C code, make it flush left (if it's less than 5 or so tabs in), cut it and paste it one line above main, then copy it again to right under main, remove the semicolon, add paired braces, move in between them, tab over and put you in insert mode.
 
 
 
 
it could be made nicer, but it gets the job done.
 
 
 
 
i guess i'm not using recording here, but that's how i generated the register. you can edit the recorded register as described here: [[VimTip144]]
 
 
 
 
 
 
 
 
 
 
 
 
 
}}
 
 
== Comments ==
 
whoops... just realized i could have done ^d$dd"2p instead of that messiness with the left shifts... oh well
 
   
 
==Comments==
Pete
 
  +
{{Todo}}
  +
Fix title &ndash; nothing to do with recording.
   
pete.vim--AT--mailnull.com
 
, December 8, 2006 14:39
 
 
----
 
----
 
Just realized I could have done ^d$dd"2p instead of that messiness with the left shifts.
The simplest way to remove all indentation on current line (if you mean that): ^d0
 
   
lx(at)ua(dot)fm
 
, December 9, 2006 14:55
 
 
----
 
----
 
The simplest way to remove all indentation on current line (if you mean that) is:
Thank you. For some reason I never think of deleting backwards...
 
  +
<pre>
  +
^d0
  +
</pre>
   
Pete Jenkins
 
, December 10, 2006 10:59
 
 
----
 
----
<!-- parsed by vimtips.py in 0.809825 seconds-->
 

Latest revision as of 00:21, 30 September 2008

Tip 1435 Printable Monobook Previous Next

created December 8, 2006 · complexity intermediate · author Peter Jenkins · version 5.7


:let @u = "<<<<<<<<<<dd?int main(^MkO^[pY/main(^M/{^M%o^M^[p^[kdd$s^M{^M^M^M}^[kki^I"

For ^M, ^I, ^[, you need to do ^v first. ^I may show up as a space. you might have to do ^v <Tab>

This will take a function prototype wherever it is in your C code, make it flush left (if it's less than 5 or so tabs in), cut it and paste it one line above main, then copy it again to right under main, remove the semicolon, add paired braces, move in between them, tab over and put you in insert mode.

I'm not using recording here, but that's how i generated the register. You can edit the recorded register as described in VimTip144.

Comments[]

 TO DO 
Fix title – nothing to do with recording.


Just realized I could have done ^d$dd"2p instead of that messiness with the left shifts.


The simplest way to remove all indentation on current line (if you mean that) is:

^d0