Changes between Version 56 and Version 57 of UsingVimWithDjango


Ignore:
Timestamp:
02/29/2012 04:32:55 PM (4 years ago)
Author:
uws@…
Comment:

Improve surround.vim additions

Legend:

Unmodified
Added
Removed
Modified
  • UsingVimWithDjango

    v56 v57  
    177177== Surround Mappings ==
    178178
    179 This is for the popular surround script [http://www.vim.org/scripts/script.php?script_id=1697 here]
    180 
    181 in your .vimrc
    182 {{{
    183 
    184 let g:surround_{char2nr("b")} = "{% block\1 \r..*\r &\1%}\r{% endblock %}"
    185 let g:surround_{char2nr("i")} = "{% if\1 \r..*\r &\1%}\r{% endif %}"
    186 let g:surround_{char2nr("w")} = "{% with\1 \r..*\r &\1%}\r{% endwith %}"
    187 let g:surround_{char2nr("c")} = "{% comment\1 \r..*\r &\1%}\r{% endcomment %}"
    188 let g:surround_{char2nr("f")} = "{% for\1 \r..*\r &\1%}\r{% endfor %}"
    189 let g:surround_{char2nr("v")} = "{{ \1 \r..*\r &\1\r }}"
    190 
    191 }}}
    192 
    193 now in visual mode type
    194 
    195     * 'sb' for block
    196     * 'si' for an if statement
    197     * 'sw' for a with statement
    198     * 'sc' for a comment
    199     * 'sf' for a for statement
    200     * 'sv' for a variable
     179These are additional surroundings for the [http://www.vim.org/scripts/script.php?script_id=1697 surround plugin]:
     180
     181{{{
     182let b:surround_{char2nr("v")} = "{{ \r }}"
     183let b:surround_{char2nr("{")} = "{{ \r }}"
     184let b:surround_{char2nr("%")} = "{% \r %}"
     185let b:surround_{char2nr("b")} = "{% block \1block name: \1 %}\r{% endblock \1\1 %}"
     186let b:surround_{char2nr("i")} = "{% if \1condition: \1 %}\r{% endif %}"
     187let b:surround_{char2nr("w")} = "{% with \1with: \1 %}\r{% endwith %}"
     188let b:surround_{char2nr("f")} = "{% for \1for loop: \1 %}\r{% endfor %}"
     189let b:surround_{char2nr("c")} = "{% comment %}\r{% endcomment %}"
     190}}}
     191
     192Put the above in ~/.vim/ftplugin/htmldjango.vim. Examples in visual mode (select some text first):
     193
     194    * type 'Sv' or 'S{' for a variable
     195    * type 'Sb' for a block
     196    * type 'Si' for an if statement
     197    * type 'Sw' for a with statement
     198    * type 'Sc' for a comment
     199    * type 'Sf' for a for statement
     200    * type 'S%' for other template tags
    201201
    202202== Pony.vim ==
Back to Top