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

Re: Simple snippet?

Expand Messages
  • Benjamin Fritz
    ... Even better (IMHO), see :help skeleton --~--~---------~--~----~------------~-------~--~----~ You received this message from the vim_use maillist. For
    Message 1 of 5 , May 1, 2008
    View Source
    • 0 Attachment
      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

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Tony Mechelynck
      ... 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
      Message 2 of 5 , May 1, 2008
      View Source
      • 0 Attachment
        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
        -~----------~----~----~----~------~----~------~--~---
      • Jürgen Krämer
        Hi, ... may I recommend to use :file instead of :saveas as the first one does not leave a spurious file if the OP later decides to cancel his work or use a
        Message 3 of 5 , May 2, 2008
        View Source
        • 0 Attachment
          Hi,

          Tony Mechelynck wrote:
          > On 01/05/08 19:05, Benjamin Fritz wrote:
          >>
          >> 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.

          may I recommend to use ":file" instead of ":saveas" as the first one
          does not leave a spurious file if the OP later decides to cancel his
          work or use a different file name?

          Regards,
          Jürgen

          --
          Sometimes I think the surest sign that intelligent life exists elsewhere
          in the universe is that none of it has tried to contact us. (Calvin)

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_use" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        Your message has been successfully submitted and would be delivered to recipients shortly.