aboutsummaryrefslogtreecommitdiff
path: root/vim/ftplugin/html.vim
blob: d2c6a3e330a51eaf14b511b3bb1449c1967db5da (plain) (blame)
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
" Run `tidy -errors -quiet` over buffer
nnoremap <buffer> <silent>
      \ <LocalLeader>c
      \ :<C-U>write !tidy -errors -quiet<CR>

" Filter buffer through `tidy`
nnoremap <buffer> <silent>
      \ <LocalLeader>t
      \ :<C-U>%!tidy -quiet<CR>

" Make a bare URL into a link to itself
function! s:UrlLink()

  " Yank this whole whitespace-separated word
  normal! yiW
  " Open a link tag
  normal! i<a href="">
  " Paste the URL into the quotes
  normal! hP
  " Move to the end of the link text URL
  normal! E
  " Close the link tag
  normal! a</a>

endfunction

" Mapping for the function above
nnoremap <buffer> <silent>
      \ <LocalLeader>r
      \ :<C-U>call <SID>UrlLink()<CR>

" Unload this filetype plugin
let b:undo_user_ftplugin
      \ = 'silent! nunmap <LocalLeader>c'
      \ . '|silent! nunmap <LocalLeader>t'
      \ . '|silent! nunmap <LocalLeader>r'