From e58f70b411ae935fcd32f00d9e3983381fdc0294 Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Wed, 26 Jun 2024 21:29:34 +0800 Subject: Update --- vim/init/config.vim | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'vim/init/config.vim') diff --git a/vim/init/config.vim b/vim/init/config.vim index 07bed12..489521f 100644 --- a/vim/init/config.vim +++ b/vim/init/config.vim @@ -10,6 +10,29 @@ " Open help page in a new tab autocmd BufEnter *.txt if &filetype == 'help' | wincmd T | endif +" Quickly edit html tag class +function! s:ChangeAttr(pattern) + + let l:attr = matchstr(getline('.'), a:pattern.'="') + if l:attr == '' + let l:all_attrs = matchstr(getline('.'), '<[[:alnum:]]\+\zs\s\?[^>]*>\ze') + execute 's/'.l:all_attrs.'/ '.a:pattern.'=""'.l:all_attrs.'/' + noh + normal! 0f"l + startinsert + else + normal! 0 + call search(l:attr) + normal! f"l + noh + startinsert + endif +endfunction + +autocmd FileType html nnoremap cl :call ChangeAttr("class") +autocmd BufLeave nunmap cl +autocmd FileType html nnoremap id :call ChangeAttr("id") +autocmd BufLeave nunmap id "---------------------------------------------------------------------- " 有 tmux 何没有的功能键超时(毫秒) -- cgit v1.2.3-70-g09d2