From 810cb9d53c09ccb8d65a4e996f088b7af3b9a40b Mon Sep 17 00:00:00 2001 From: Tom Ryder Date: Fri, 3 Nov 2017 21:55:48 +1300 Subject: 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. --- vim/ftplugin/html.vim | 12 ++++++++++-- 1 file 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 v :exe :call HTMLTidy() " Make a bare URL into a link to itself function! s:UrlLink() + + " Yank this whole whitespace-separated word normal! yiW - execute 'normal! i + " Paste the URL into the quotes + normal! hP + " Move to the end of the link text URL normal! E - execute 'normal! a\' + " Close the link tag + normal! a + endfunction nnoremap r :call UrlLink() -- cgit v1.2.3