path: root/vim/ftplugin/html.vim
diff options
authorTom Ryder <tom@sanctum.geek.nz>2017-11-03 21:55:48 +1300
committerTom Ryder <tom@sanctum.geek.nz>2017-11-03 22:17:32 +1300
commit810cb9d53c09ccb8d65a4e996f088b7af3b9a40b (patch)
tree6e4e1dd1bba58793d434cd67965bc615feba468a /vim/ftplugin/html.vim
parent4a7b3b3cc29ed48a96535284446d921be414fb0b (diff)
Refactor UrlLink() function normal! commands
Tidy up the 'normal!' commands and comment them in appropriate groups. Take advantage of the natural command-termination at the end of a 'normal!' string to end insert mode. It would be better to do all of this with pure VimL functions, but I don't know how yet.
Diffstat (limited to 'vim/ftplugin/html.vim')
1 files changed, 10 insertions, 2 deletions
diff --git a/vim/ftplugin/html.vim b/vim/ftplugin/html.vim
index b4eb9e6b..7400326c 100644
--- a/vim/ftplugin/html.vim
+++ b/vim/ftplugin/html.vim
@@ -6,9 +6,17 @@ nnoremap <LocalLeader>v :exe :<C-U>call <SID>HTMLTidy()<CR>
" Make a bare URL into a link to itself
function! s:UrlLink()
+ " Yank this whole whitespace-separated word
normal! yiW
- execute 'normal! i<a href="<C-R>0><Esc>'
+ " 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
- execute 'normal! a</a>\<Esc>'
+ " Close the link tag
+ normal! a</a>
nnoremap <silent> <LocalLeader>r :<C-U>call <SID>UrlLink()<CR>