On 21/01/10 00:19, Gary Johnson wrote:
On 2010-01-20, smu johnson wrote:

On Wed, Jan 20, 2010 at 2:57 PM, smu johnson<[email protected]>  wrote:

     On Wed, Jan 20, 2010 at 2:46 PM, Gary Johnson<[email protected]>  wrote:


            :help :startinsert


     Hi!

     If i do startinsert! in the if statement... and then try to write the
     following if statement, i'm quite sure how to "write" text without it
     thinking that my if statement itself is the text I want to write.

       if a:pos == "comment_and_write"
         startappend!
       else
         startinsert!
       endif

     if (condition)
       the big brown fox jumped over the lazy dog
       stopinsert
     endif

     <--- confused :(

Me, too.

Perhaps it cannot be done.

NOTE: These commands cannot be used with |:global| or |:vglobal|.
":append" and ":insert" don't work properly in between ":if" and
":endif", ":for" and ":endfor", ":while" and ":endwhile".

*sad face*

Hi,

I'm not sure what you're trying to accomplish.  You've given
examples of attempted solutions that don't work, but it's not clear
to me what you're trying to get vim to do.  It may be that it can be
done, just not the way you're approaching it.

Regards,
Gary




If it's just to insert a given piece or text above or below the current line, you could for instance write that text into a register (with either a "\n" in a double-quoted string, or a null, where a line break is desired)...

        let @@ = "Line 1\n---second line---\nline three\nLAST LINE"

(see :help :let-@) ...and then, maybe within or after an if-clause, do either

        put
or
        .-1put

or even compute the line number (of the line after which to insert, or zero for "before first line"), then

        exe lineno 'put'

with an optional register-letter (default: the "unnamed" register of course) after the :put (see :help :put). (In theory this could be accomplished in one step by means of the expression register, but I haven't succeeded to get line breaks into the expression register.)


Best regards,
Tony.
--
Q:  What is "SMOORPLAY"?
A:  It's what SMURFS do before they SMUCK, of course!

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or 
reply to this email with the words "REMOVE ME" as the subject.

Reply via email to