Problem is, once I do normal! I, it automatically escapes out of insert mode
afterwords.  I need it to "stay there" and let a few if statements process.
Once that happens, I'm hoping to write in text while it's in this mode.
Something else I am not sure how to do.

Example:  (section of a function)


  if a:pos == "comment_and_write"
    normal! A
  else
    normal! I
  endif

  if a:syn == "vim"
    " write " here
  elseif a:syn == "c"
    " write // here

A couple ideas:

1)  build up a string and then execute it:

  if ...
    let s = "A"
  else
    let s = "I"
  if ...
    let s .= "stuff"
  else
    let s .= "other stuff"
  exec "norm ".s.expand('<esc>')

(not quite sure if that expand() call will work...just shooting untested there :)


2) choose to do it without normal mode:

  if a:syn == "vim"
    let comment='"'
  elseif a:syn == 'c'
    let comment='//'
  ...
  if a:pos == "comment_and_write"
    s/$/\=comment
  else
    put =comment

3) similar to #2, use the expression register to evaluate things and put in the appropriate character:

inoremap <f4> <c-r>=(a:syn=='vim')?('"'):((a:syn=='c')?('//'):(default_or_more_logic_here))<cr>

(all on one line in case mailers between here and there break things...it's untested, but should be fairly close and at least give you the pattern to use).


4) some combination of #2 and #3, using inoremap for the insert mode and nnoremap for the append mode. Not quite sure what you're trying to accomplish in that regard, but it's at least something to consider.

Hopefully that gives you a few more ideas,

-tim






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

Reply via email to