Re: How do I implement boilerplate text?

2006-11-03 Thread Richard Querin

Thanks to all, the abbreviation method seems to work now. I had used
'abbreviate' in my _vimrc file and it wasn't working. I changed it to
'ab' and it works fine. I'm not sure if I read the message wrong or if
both should work.

Anyway thanks again for all the help.

On 11/2/06, Yegappan Lakshmanan [EMAIL PROTECTED] wrote:

On 11/2/06, Bill McCarthy [EMAIL PROTECTED] wrote:
 On Thu 2-Nov-06 4:11pm -0600, Richard Querin wrote:

  The abbreviation method seems the simplest for me at the
  moment, but I can't seem to figure out how to make a
  multiline abbreviation in my .vimrc file. I've tried using
  CR characters in the string and quoting it as well..
  both to no avail. Any hints?

 Actually, using the CR characters should work fine.
 Perhaps you have some setting interfering.  You should be


Check the 'cpoptions' option setting. To use symbolic representation
of key codes in maps and abbreviations, make sure  the '' flag is
not present in 'cpoptions'. To use raw key-codes in a map or
abbreviation, make sure the 'k' flag is not present in 'cpoptions'.

- Yegappan

 able to place the following in a script file (or your
 vimrc):

 ab lhs This is line 1.CR
 \This is line 2.CR
 \This is line 3.

 For a simple test, start gvim without any mods:

 gvim -u NONE -i NONE -N

 And define an abbreviate call abb:

 :ab abb ThisCRisCRaCRtest.

 Now type:  iabbenter
 where enter is the enter key.

 --
 Best regards,
 Bill





Re: How do I implement boilerplate text?

2006-11-02 Thread Tim Chase

Anyway, one thing I'd like to be able to do is insert some
boilerplate text into a document - something like a standard
signature. Is there some way I can preload a buffer with this
text when I run Vim? Can this be done in the rc file? I'm sure
there is a way (with Vim there always seems to be) but I can't
seem to find out how.



In your vimrc, you can add a line something like

au BufNewFile *.txt $r ~/template.txt

where *.txt is the pattern to match.  Thus, if you do:

:e nonexistant.txt

it will automatically read in the file ~/template.txt at the 
bottom of the file ($).


This can be modified for most templating needs.  You can change 
the filespec to just * to have it apply to all new files.  You 
can change the file that is read in.  You can also position it 
elsewhere in the file by changing the $ to any other address, 
such as reading at the beginning (0).  When you're dealing with 
an empty/new file, this isn't such a big deal though ;)


There are a number of bigger and more powerful templating scripts 
available, such as


http://vim.sourceforge.net/scripts/script.php?script_id=988
http://vim.sourceforge.net/scripts/script.php?script_id=1160

which may be a bit like hunting mosquitoes with a bazooka, or 
might be just what you need.


-tim






Re: How do I implement boilerplate text?

2006-11-02 Thread Yegappan Lakshmanan

On 11/2/06, Bill McCarthy [EMAIL PROTECTED] wrote:

On Thu 2-Nov-06 4:11pm -0600, Richard Querin wrote:

 The abbreviation method seems the simplest for me at the
 moment, but I can't seem to figure out how to make a
 multiline abbreviation in my .vimrc file. I've tried using
 CR characters in the string and quoting it as well..
 both to no avail. Any hints?

Actually, using the CR characters should work fine.
Perhaps you have some setting interfering.  You should be



Check the 'cpoptions' option setting. To use symbolic representation
of key codes in maps and abbreviations, make sure  the '' flag is
not present in 'cpoptions'. To use raw key-codes in a map or
abbreviation, make sure the 'k' flag is not present in 'cpoptions'.

- Yegappan


able to place the following in a script file (or your
vimrc):

ab lhs This is line 1.CR
\This is line 2.CR
\This is line 3.

For a simple test, start gvim without any mods:

gvim -u NONE -i NONE -N

And define an abbreviate call abb:

:ab abb ThisCRisCRaCRtest.

Now type:  iabbenter
where enter is the enter key.

--
Best regards,
Bill