sponsor Vim development Vim logo Vim Book Ad

HtmlHelper : Html macros and mappings

 script karma  Rating 4/3, Downloaded by 867    Comments, bugs, improvements  Vim wiki

created by
Dimitar Dimitrov
 
script type
ftplugin
 
description
" Html macros and mappings for:
" ------------------------------------------
"
"    *  Closing        an opening tag
"    *  Wrapping     text with tags
"    *  Increasing    the weight of header tags (<h1>...)
"    *  Formatting    text inside a pair of tags
"    *  Rearranging  <tag> content </tag> vertically
"    *  Stripping       outer tags
"    *  'Spacing'       vertically the content of a pair of tags
"
" 1. Close an opening tag
" -----------------------
"
"     >> : <tag> newline </tag> (write quickly a second > after the first one)
"     >/ : <tag>         </tag>
"     <? : <?php             ?>
"
" 2. Wrapping:
" ------------
"
"         +-----------+-------------------+
"         | paragraph | WORD or selection |
" +-------+-----------+-------------------+
" | <ul>  |    @u     |        \u         |
" | <ol>  |    @o     |        \o         |
" | <p>   |    @p     |        \p         |
" | <div> |    @d     |        \d         |
" +-------+-----------+-------------------+
"
" Note: \u and \o work on fully selected lines only
"
" Note: mnemo for paragraphs and lines: wrap @ll
"
" Note: You can use a count with the \ mappings
"
"              +------+-------------------+
"              | line | WORD or selection |
" +------------+------+-------------------+
" | <td>       |  @t  |        \t         |
" | <a>        |  @a  |        \a         |
" | <span>     |  @s  |        \s         |
" | <h1>       |  @h  |        \h         |
" | <li>       |  @l  |        \l         |
" | <!-- -->   |  @c  |        \c         |
" | <em>       |  @e  |        \e         |
" | <strong>   |  @b  |        \b         |
" +------------+------+-------------------+
"
" 3. Insert an image
" ------------------
"
"     @i (<img src='X' alt='' title='' />)
"
" 4. Set the class of a tag
" -------------------------
"
"     :Class ul         -> <ul>                 (default)
"     :Class ul bg_blue -> <ul class='bg_blue'>
"
" Note: Try using :C or :Cl or... instead of :Class. Depending on the
"       installed plugins, a shorter or longer abbreviation might work.
"
" Shortcuts: (:C shortcut)
"     d,   s,    u,  o,  h,  l,  t,  i,   e,  b
"     div, span, ul, ol, h1, li, td, img, em, strong
"
" Note: If you don't want to write a tag manually, you can use <tab>
"       after :Class to autocomplete your tag.
"       (put a space after :Class before hitting <tab>)
"
" 5. <hn -> <hn+1 (Use after a @h or \h)
" --------------------------------------
"
"     @j (mnemo: j is just besides h on the keyboard)
"
" 6. gq inside a pair of tags
" ---------------------------
"
"     @g for standard tags
"     \g for <!-- --> or <?php ?>
"
" 7. Rearrange <tag> content </tag> vertically
" --------------------------------------------
"
"     @r for standard tags
"     \r for <!-- --> or <?php ?>
"
" 8. Strip outer tags
" -------------------
"
"     @x for standard tags
"     \x for <!-- --> or <?php ?>
"
" 9. 'Space' vertically the content of a pair of tags
" ---------------------------------------------------
"
"     @m for standard tags        (mnemo:
)
"     \m for <!-- --> or <?php ?>
"
" A detailed help is in the comments of the file itself!
 
install details
HtmlHelper - Install in:

              ~/.vim/ftplugin/html.vim
       ln -s ~/.vim/ftplugin/html.vim phtml.vim
       ln -s ~/.vim/ftplugin/html.vim xml.vim

Tabular.vim: (http://github.com/godlygeek/tabular/tree/master)

             ~/.vim/autoload/tabular.vim
             ~/.vim/after/plugin/myTabularMaps.vim (to be created, see above)
             ~/.vim/plugin/Tabular.vim
             ~/.vim/plugin/TabularMaps.vim
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
html.vim 2.2 2010-09-13 7.0 Dimitar Dimitrov Some minor changes
html.vim.tar.gz 2.1 2009-09-27 7.0 Dimitar Dimitrov @e will now correctly use the class set with :C em ...
html.vim 2.0 2009-09-27 7.0 Dimitar Dimitrov Changes:

    @i -> <img> instead if <i> (not valid XHTML 1.1 strict)
    @b -> <strong> instead of <b> (not valid XHTML 1.1 strict)
    @e -> <em>

    :Class can be invoked with these shortcuts now:

    d,   s,    u,  o,  h,  l,  t,  i,   e,  b
    div, span, ul, ol, h1, li, td, img, em, strong

    Pointed out a limitation:

    7@p won't work if one of the paragraphs starts with a one letter word
    (ex: I). Same for <> 7 or another macro or on words.

    TODO:

    <fieldset> |  @f
    <kbd>      |  @k
    <noscript> |  @n
    <var>      |  @v

    <meta>     -> @m
html.vim.tar.gz 1.0 2009-06-07 7.0 Dimitar Dimitrov Initial upload
ip used for rating: 54.161.143.22

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo