Loading ...
Sorry, an error occurred while loading the content.

137505Re: Open a template with cursor set on a specific line?

Expand Messages
  • Tim Chase
    May 5, 2013
    • 0 Attachment
      On 2013-05-05 10:13, Gregory Caughey wrote:
      > I've created a simple template to be called when invoking the
      > Calendar plugin via Vim. I want to use this for Administrative
      > Logging, so am using modeline to format and set the document
      > environment. I want to automate the cursor position so it is placed
      > after my header where the message body starts. Can I make Vim
      > (7.3.*) behave this way? Thanks, Greg

      The short answer is almost positively yes.

      Longer answer:

      1) I'm not familiar with the Calendar plugin, and
      2) you don't mention how the header and body are delimited, and
      3) it likely can't be done via a modeline alone, but

      taking that into consideration, you can do something like (or add to
      your vimrc)

      :autocmd BufRead my_calendar_file_glob*.txt /========/+

      where, in this case "/=======/" is some pattern that finds the
      delimiter. The "+" just moves the cursor to the line following the
      delimiter. If the file was a Maildir file, it would have a bunch of
      headers, then a blank line, then the body, so you'd use

      /^$/+

      to put the cursor on the line following the blank line (the first
      line of the body).

      There might be a wrinkle if the Calendar plugin has its own BufRead
      events that might clash, or if it's harder to pinpoint your file with
      a particular file-glob.

      With a few more details, it might be possible to nail down a more
      definitive solution.

      -tim








      --
      --
      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

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Show all 2 messages in this topic