File: html.vim

package info (click to toggle)
cream 0.43-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,260 kB
  • sloc: sh: 323; php: 261; makefile: 5
file content (157 lines) | stat: -rw-r--r-- 4,362 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
"
" cream-filetype-html.vim
" 
" Cream -- An easy-to-use configuration of the famous Vim text editor
" [ http://cream.sourceforge.net ] Copyright (C) 2001-2011 Steve Hall
" 
" License:
" This program is free software; you can redistribute it and/or modify
" it under the terms of the GNU General Public License as published by
" the Free Software Foundation; either version 3 of the License, or
" (at your option) any later version.
" [ http://www.gnu.org/licenses/gpl.html ]
" 
" This program is distributed in the hope that it will be useful, but
" WITHOUT ANY WARRANTY; without even the implied warranty of
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
" General Public License for more details.
" 
" You should have received a copy of the GNU General Public License
" along with this program; if not, write to the Free Software
" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
" 02111-1307, USA.
"
" Notes:
" * We've reserved Alt+[letter] combinations for language specific functions.
" * This stuff belongs in other (individual?) files, perhaps loadable from the menu.


setlocal commentstring=<!--%s-->
setlocal comments+=s1:\<!--,mb:\\t,ex:-->

" we do not like Vim's autoindent in HTML!
setlocal indentexpr=""
setlocal noautoindent

""	Insert HTML <li> item
"imap <M-l> <li></li><Left><Left><Left><Left><Left>

"	Insert HTML <ol> structure
"*** BROKEN: <C-o> is the mapping for single command mode!! ***
"imap <C-o> <ol><CR><li></li><CR></ol><CR><Up><Up><Right><Right><Right><Right>

""	Insert HTML <ul> structure
"" * Note: "<C-S><C-u>" doesn't work.
"imap <M-u> <ul><CR><li></li><CR></ul><CR><Up><Up><Right><Right><Right><Right>

""	Insert HTML <b></b> pair
"imap <C-b> <C-o>:call Cream_html_bold()<CR>
"function! Cream_html_bold()
"    normal i<b></b>
"    normal hhh
"endfunction
"	Insert HTML <b></b> pair, pasting selection within
vmap <silent> <C-b> :<C-u>call Cream_html_bold_select("v")<CR>
function! Cream_html_bold_select(mode)

	if a:mode == "v"
		normal gv
	else
		return
	endif
	
	" cut
 	normal "xx

	let @x = "\<b>" . @x . "\</b>"
	normal "xP

	" re-select 
	normal gv

	" adjust for added chars inserted
	normal o
	execute "normal lll"
	normal o
	execute "normal lll"
	normal o

endfunction

""	Insert HTML <i></i> pair
""*** Broken *** (interfering with [Tab])
""imap <C-i> <C-o>:call Cream_html_italicize()<CR>
"function! Cream_html_italicize()
"    normal i<i></i>
"    normal hhh
"endfunction
"	Insert HTML <i></i> pair, pasting selection within
"*** Broken *** (interfering with [Tab])
"vmap <C-i> "xxh:call Cream_html_italicize_select()<CR>
function! Cream_html_italicize_select()
	let mystr = @x
	let mystr = "\<i>" . mystr . "\</i>"
	let @x = mystr
	normal "xp
	" now re-select, and adjust for added chars inserted
	normal gv
	normal o
	execute "normal lll"
	normal O
	execute "normal lll"
	normal o
endfunction

"*** BROKEN: Conflicts with other :<C-u>call... stuff
"""	Insert HTML <u></u> pair
""imap <C-u> <C-o>:call Cream_html_underline()<CR>
""function! Cream_html_underline()
""    normal i<u></u>
""    normal hhh
""endfunction
""	Insert HTML <u></u> pair, pasting selection within
"vmap <C-u> "xxh:call Cream_html_underline_select()<CR>
"function! Cream_html_underline_select()
"    let mystr = @x
"    let mystr = "\<u>" . mystr . "\</u>"
"    let @x = mystr
"    normal "xp
"    " now re-select, and adjust for added chars inserted
"    normal gv
"    normal o
"    execute "normal lll"
"    normal O
"    execute "normal lll"
"    normal o
"endfunction
"***

""	Insert "&nbsp;"
""nmap <M-Space> i&nbsp;
"imap <M-Space> &nbsp;

""	Insert header (<h#>)
"imap <M-1> <h1></h1><Left><Left><Left><Left><Left>
"imap <M-2> <h2></h2><Left><Left><Left><Left><Left>
"imap <M-3> <h3></h3><Left><Left><Left><Left><Left>
"imap <M-4> <h4></h4><Left><Left><Left><Left><Left>
"imap <M-5> <h5></h5><Left><Left><Left><Left><Left>
"imap <M-6> <h6></h6><Left><Left><Left><Left><Left>

""	Insert HTML <p></p>
""nmap <M-p> i<p></p><Left><Left><Left><Left>
"imap <M-p>  <p></p><Left><Left><Left><Left>
""vmap <M-p> <Esc>i<p></p><Left><Left><Left><Left>


" HTML Character Equivalences

"" ">" to "&gt;" (remember, this is [Alt]+[Shift]+[.] ;)
"imap <M-<> &lt;
"" "<" to "&lt;" (remember, this is [Alt]+[Shift]+[,] ;)
"imap <M->> &gt;
"" "&" to "&amp;"
"imap <M-&> &amp;
"" """ to "&quot;"
"imap <M-"> &quot;