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 |
| 179 | These are additional surroundings for the [http://www.vim.org/scripts/script.php?script_id=1697 surround plugin]: |
| 180 | |
| 181 | {{{ |
| 182 | let b:surround_{char2nr("v")} = "{{ \r }}" |
| 183 | let b:surround_{char2nr("{")} = "{{ \r }}" |
| 184 | let b:surround_{char2nr("%")} = "{% \r %}" |
| 185 | let b:surround_{char2nr("b")} = "{% block \1block name: \1 %}\r{% endblock \1\1 %}" |
| 186 | let b:surround_{char2nr("i")} = "{% if \1condition: \1 %}\r{% endif %}" |
| 187 | let b:surround_{char2nr("w")} = "{% with \1with: \1 %}\r{% endwith %}" |
| 188 | let b:surround_{char2nr("f")} = "{% for \1for loop: \1 %}\r{% endfor %}" |
| 189 | let b:surround_{char2nr("c")} = "{% comment %}\r{% endcomment %}" |
| 190 | }}} |
| 191 | |
| 192 | Put 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 |