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

90028Re: Simple snippet?

Expand Messages
  • Tony Mechelynck
    May 1, 2008
      On 01/05/08 19:05, Benjamin Fritz wrote:
      > On 5/1/08, Tony Mechelynck<antoine.mechelynck@...> wrote:
      >> On 01/05/08 17:23, 703designs wrote:
      >> > I want to map ,xhtml to output:
      >> >
      >> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      >> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      >> >
      >> > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      >> > <head>
      >> > <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
      >> >
      >> > This would be used as a quick way to start XHTML docs. I mapped ,xhtml
      >> > to a function successfully, but the function throws errors. What's the
      >> > best way to make this sort of output with a Vim script?
      >>
      >>
      >> For such a simple thing you don't need a function. Just create a file
      >> ~/null.xhtml with the contents:
      >>
      >>
      >> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      >> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      >> <head>
      >> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      >>
      >> </head>
      >> <body>
      >> </body>
      >> </html>
      >>
      >> Then to start your HTML docs, use
      >>
      >> :e ~/null.xhtml
      >> :saveas<filename>
      >>
      >> where<filename> is the desired filename (with path if necessary).
      >> Or even create a new Ex-Command, as follows:
      >>
      >> command NewXHTML -bar -bang -nargs=1 -complete=file
      >> \ e ~/null.xhtml | saveas<bang> <args>
      >>
      >>
      >> Best regards,
      >> Tony.
      >>
      >
      > Even better (IMHO), see :help skeleton
      >
      Note that using ":0r" in an empty buffer, as recommended by ":h
      skeleton", will leave a spurious empty line at the end of the file.
      ":saveas", as shown above, doesn't have that limitation.

      Best regards,
      Tony.
      --
      Due to lack of disk space, this fortune database has been
      discontinued.

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Show all 5 messages in this topic