aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
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
parentUse single quotes for HTML link mapping :execute (diff)
downloaddotfiles-810cb9d53c09ccb8d65a4e996f088b7af3b9a40b.tar.gz
dotfiles-810cb9d53c09ccb8d65a4e996f088b7af3b9a40b.zip
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.
-rw-r--r--vim/ftplugin/html.vim12
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>
+
endfunction
nnoremap <silent> <LocalLeader>r :<C-U>call <SID>UrlLink()<CR>