Friday, December 25, 2009

Re: Correct easily if without block instructions code

On 26/11/09 18:44, epanda wrote:
[top-posted reply reordered]
> On 26 nov, 18:36, Francisco Dibar<frandi...@gmail.com> wrote:
>> On Thu, Nov 26, 2009 at 11:06 AM, epanda<callingel...@hotmail.fr> wrote:
>>> I would like to know if I have to add instructions bloc in this case :
>>
>>> if ( cond1&&
>>> cond2 )
>>
>>> /* general comment
>>> // a comment
>>
>>> *
>>> */
>>
>>> return result;
>>
>>> ==> has to become
>>
>>> if ( cond1&&
>>> cond2 )
>>> {
>>> /* general comment
>>> // a comment
>>
>>> *
>>> */
>>> return result;
>>> }
>>
>> If I understood you well, you need to surround some lines of code
>> between braces. That can be done with the surround plugin as follows:
>> - select the lines of text you wish to surround
>> - type s{
>>
>> To indent properly, you can type vi{ to select the block of text
>> between braces, and then type = (or shift+>) to indent correctly.
>>
>> bye.
>
> Yes, I want to surround first line of code after if instruction ...
>
> but with vimscript, not from normal mode
>

what about (untested, and starting with the cursor on the line
containing the closing parenthese at the end of the "if")

put ='{'
/;$/put ='}'

Best regards,
Tony.
--
... If forced to travel on an airplane, try and get in the cabin with
the Captain, so you can keep an eye on him and nudge him if he falls
asleep or point out any mountains looming up ahead ...
-- Mike Harding, "The Armchair Anarchist's Almanac"

--
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

No comments: