aboutsummaryrefslogtreecommitdiffhomepage
path: root/vim/init/config.vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim/init/config.vim')
-rw-r--r--vim/init/config.vim23
1 files changed, 23 insertions, 0 deletions
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 @@
10" Open help page in a new tab 10" Open help page in a new tab
11autocmd BufEnter *.txt if &filetype == 'help' | wincmd T | endif 11autocmd BufEnter *.txt if &filetype == 'help' | wincmd T | endif
12 12
13" Quickly edit html tag class
14function! s:ChangeAttr(pattern)
15
16 let l:attr = matchstr(getline('.'), a:pattern.'="')
17 if l:attr == ''
18 let l:all_attrs = matchstr(getline('.'), '<[[:alnum:]]\+\zs\s\?[^>]*>\ze')
19 execute 's/'.l:all_attrs.'/ '.a:pattern.'=""'.l:all_attrs.'/'
20 noh
21 normal! 0f"l
22 startinsert
23 else
24 normal! 0
25 call search(l:attr)
26 normal! f"l
27 noh
28 startinsert
29 endif
30endfunction
31
32autocmd FileType html nnoremap <leader>cl :call <SID>ChangeAttr("class")<CR>
33autocmd BufLeave nunmap <leader>cl
34autocmd FileType html nnoremap <leader>id :call <SID>ChangeAttr("id")<CR>
35autocmd BufLeave nunmap <leader>id
13 36
14"---------------------------------------------------------------------- 37"----------------------------------------------------------------------
15" 有 tmux 何没有的功能键超时(毫秒) 38" 有 tmux 何没有的功能键超时(毫秒)