Mercurial > vim
changeset 11:eeda6b1401ae
changing files to .vim
| author | luka |
|---|---|
| date | Fri, 28 Nov 2025 08:45:17 -0500 |
| parents | 9c80955f0c6e |
| children | 08bdff1abb15 |
| files | .vimrc plugins/ale plugins/ale.vim plugins/coc plugins/coc.vim plugins/ctrlp plugins/ctrlp.vim plugins/nerdtree plugins/nerdtree.vim plugins/taghelp plugins/taghelp.vim test.vim |
| diffstat | 11 files changed, 301 insertions(+), 301 deletions(-) [+] |
line wrap: on
line diff
--- a/.vimrc Fri Oct 31 14:24:31 2025 -0400 +++ b/.vimrc Fri Nov 28 08:45:17 2025 -0500 @@ -6,7 +6,7 @@ inoremap <C-a> <C-x><C-i> " Support for tags closing and classes -source $HOME/.vim/plugins/taghelp +source $HOME/.vim/plugins/taghelp.vim source $HOME/.vim/plugins/dbtables/dbtables.vim source $HOME/.vim/plugins/hghelp/hghelp.vim source $HOME/.vim/plugins/globalsearch.vim @@ -83,17 +83,17 @@ " Environment Plugins " " NERDTree -source $HOME/.vim/plugins/nerdtree +source $HOME/.vim/plugins/nerdtree.vim " Coding and language specifics " " LSP - ale -source $HOME/.vim/plugins/ale +source $HOME/.vim/plugins/ale.vim " Blade Plug 'jwalton512/vim-blade', { 'for': 'php' } " Use release branch (recommended) -source $HOME/.vim/plugins/coc +source $HOME/.vim/plugins/coc.vim " AI-ify Plug 'madox2/vim-ai' @@ -106,7 +106,7 @@ call plug#end() " CTRLP -source $HOME/.vim/plugins/ctrlp +source $HOME/.vim/plugins/ctrlp.vim " Netwr set nocp
--- a/plugins/ale Fri Oct 31 14:24:31 2025 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -" LSP client -Plug 'dense-analysis/ale' - -let g:ale_php_langserver_executable = expand('~/.config/composer/vendor/phpactor/language-server/bin/serve.php') - -let g:ale_linters = { -\ 'php': ['phpcs', 'phpstan', 'psalm', 'ctags'], -\} - -let g:ale_php_ctags_executable = 'ctags' - -" Enable completion where available. -" This setting must be set before ALE is loaded. -" -" You should not turn this setting on if you wish to use ALE as a completion -" source for other completion plugins, like Deoplete. -let g:ale_completion_enabled = 0 -let g:ale_sign_column_always = 1 -let g:ale_lint_delay = 500
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/ale.vim Fri Nov 28 08:45:17 2025 -0500 @@ -0,0 +1,19 @@ +" LSP client +Plug 'dense-analysis/ale' + +let g:ale_php_langserver_executable = expand('~/.config/composer/vendor/phpactor/language-server/bin/serve.php') + +let g:ale_linters = { +\ 'php': ['phpcs', 'phpstan', 'psalm', 'ctags'], +\} + +let g:ale_php_ctags_executable = 'ctags' + +" Enable completion where available. +" This setting must be set before ALE is loaded. +" +" You should not turn this setting on if you wish to use ALE as a completion +" source for other completion plugins, like Deoplete. +let g:ale_completion_enabled = 0 +let g:ale_sign_column_always = 1 +let g:ale_lint_delay = 500
--- a/plugins/coc Fri Oct 31 14:24:31 2025 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,163 +0,0 @@ -Plug 'neoclide/coc.nvim', {'branch': 'release'} -" https://raw.githubusercontent.com/neoclide/coc.nvim/master/doc/coc-example-config.vim - -" May need for Vim (not Neovim) since coc.nvim calculates byte offset by count -" utf-8 byte sequence -set encoding=utf-8 -" Some servers have issues with backup files, see #649 -set nobackup -set nowritebackup - -" Having longer updatetime (default is 4000 ms = 4s) leads to noticeable -" delays and poor user experience -set updatetime=300 - -" Always show the signcolumn, otherwise it would shift the text each time -" diagnostics appear/become resolved -set signcolumn=yes - -" Use tab for trigger completion with characters ahead and navigate -" NOTE: There's always complete item selected by default, you may want to enable -" no select by `"suggest.noselect": true` in your configuration file -" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by -" other plugin before putting this into your config -inoremap <silent><expr> <TAB> - \ coc#pum#visible() ? coc#pum#next(1) : - \ CheckBackspace() ? "\<Tab>" : - \ coc#refresh() -inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>" - -" Make <CR> to accept selected completion item or notify coc.nvim to format -" <C-g>u breaks current undo, please make your own choice -inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() - \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" - -function! CheckBackspace() abort - let col = col('.') - 1 - return !col || getline('.')[col - 1] =~# '\s' -endfunction - -" Use <c-space> to trigger completion -if has('nvim') - inoremap <silent><expr> <c-space> coc#refresh() -else - inoremap <silent><expr> <c-@> coc#refresh() -endif - -" Use `[g` and `]g` to navigate diagnostics -" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list -nmap <silent> [g <Plug>(coc-diagnostic-prev) -nmap <silent> ]g <Plug>(coc-diagnostic-next) - -" GoTo code navigation -nmap <silent> gd <Plug>(coc-definition) -nmap <silent> gy <Plug>(coc-type-definition) -nmap <silent> gi <Plug>(coc-implementation) -nmap <silent> gr <Plug>(coc-references) - -" Use K to show documentation in preview window -nnoremap <silent> K :call ShowDocumentation()<CR> - -function! ShowDocumentation() - if CocAction('hasProvider', 'hover') - call CocActionAsync('doHover') - else - call feedkeys('K', 'in') - endif -endfunction - -" Highlight the symbol and its references when holding the cursor -autocmd CursorHold * silent call CocActionAsync('highlight') - -" Symbol renaming -nmap <leader>rn <Plug>(coc-rename) - -" Formatting selected code -xmap <leader>f <Plug>(coc-format-selected) -nmap <leader>f <Plug>(coc-format-selected) - -augroup mygroup - autocmd! - " Setup formatexpr specified filetype(s) - autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') - " Update signature help on jump placeholder - autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') -augroup end - -" Applying code actions to the selected code block -" Example: `<leader>aap` for current paragraph -xmap <leader>a <Plug>(coc-codeaction-selected) -nmap <leader>a <Plug>(coc-codeaction-selected) - -" Remap keys for applying code actions at the cursor position -nmap <leader>ac <Plug>(coc-codeaction-cursor) -" Remap keys for apply code actions affect whole buffer -nmap <leader>as <Plug>(coc-codeaction-source) -" Apply the most preferred quickfix action to fix diagnostic on the current line -nmap <leader>qf <Plug>(coc-fix-current) - -" Remap keys for applying refactor code actions -nmap <silent> <leader>re <Plug>(coc-codeaction-refactor) -xmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected) -nmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected) - -" Run the Code Lens action on the current line -nmap <leader>cl <Plug>(coc-codelens-action) - -" Map function and class text objects -" NOTE: Requires 'textDocument.documentSymbol' support from the language server -xmap if <Plug>(coc-funcobj-i) -omap if <Plug>(coc-funcobj-i) -xmap af <Plug>(coc-funcobj-a) -omap af <Plug>(coc-funcobj-a) -xmap ic <Plug>(coc-classobj-i) -omap ic <Plug>(coc-classobj-i) -xmap ac <Plug>(coc-classobj-a) -omap ac <Plug>(coc-classobj-a) - -" Remap <C-f> and <C-b> to scroll float windows/popups -if has('nvim-0.4.0') || has('patch-8.2.0750') - nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" - nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" - inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" - inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" - vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" - vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" -endif - -" Use CTRL-S for selections ranges -" Requires 'textDocument/selectionRange' support of language server -nmap <silent> <C-s> <Plug>(coc-range-select) -xmap <silent> <C-s> <Plug>(coc-range-select) - -" Add `:Format` command to format current buffer -command! -nargs=0 Format :call CocActionAsync('format') - -" Add `:Fold` command to fold current buffer -command! -nargs=? Fold :call CocAction('fold', <f-args>) - -" Add `:OR` command for organize imports of the current buffer -command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') - -" Add (Neo)Vim's native statusline support -" NOTE: Please see `:h coc-status` for integrations with external plugins that -" provide custom statusline: lightline.vim, vim-airline -set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} - -" Mappings for CoCList -" Show all diagnostics -nnoremap <silent><nowait> <Leader>ca :<C-u>CocList diagnostics<cr> -" Manage extensions -nnoremap <silent><nowait> <Leader>ce :<C-u>CocList extensions<cr> -" Show commands -nnoremap <silent><nowait> <Leader>cc :<C-u>CocList commands<cr> -" Find symbol of current document -nnoremap <silent><nowait> <Leader>co :<C-u>CocList outline<cr> -" Search workspace symbols -nnoremap <silent><nowait> <Leader>cs :<C-u>CocList -I symbols<cr> -" Do default action for next item -nnoremap <silent><nowait> <Leader>cj :<C-u>CocNext<CR> -" Do default action for previous item -nnoremap <silent><nowait> <Leader>ck :<C-u>CocPrev<CR> -" Resume latest coc list -nnoremap <silent><nowait> <Leader>cp :<C-u>CocListResume<CR>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/coc.vim Fri Nov 28 08:45:17 2025 -0500 @@ -0,0 +1,163 @@ +Plug 'neoclide/coc.nvim', {'branch': 'release'} +" https://raw.githubusercontent.com/neoclide/coc.nvim/master/doc/coc-example-config.vim + +" May need for Vim (not Neovim) since coc.nvim calculates byte offset by count +" utf-8 byte sequence +set encoding=utf-8 +" Some servers have issues with backup files, see #649 +set nobackup +set nowritebackup + +" Having longer updatetime (default is 4000 ms = 4s) leads to noticeable +" delays and poor user experience +set updatetime=300 + +" Always show the signcolumn, otherwise it would shift the text each time +" diagnostics appear/become resolved +set signcolumn=yes + +" Use tab for trigger completion with characters ahead and navigate +" NOTE: There's always complete item selected by default, you may want to enable +" no select by `"suggest.noselect": true` in your configuration file +" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by +" other plugin before putting this into your config +inoremap <silent><expr> <TAB> + \ coc#pum#visible() ? coc#pum#next(1) : + \ CheckBackspace() ? "\<Tab>" : + \ coc#refresh() +inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>" + +" Make <CR> to accept selected completion item or notify coc.nvim to format +" <C-g>u breaks current undo, please make your own choice +inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() + \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" + +function! CheckBackspace() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use <c-space> to trigger completion +if has('nvim') + inoremap <silent><expr> <c-space> coc#refresh() +else + inoremap <silent><expr> <c-@> coc#refresh() +endif + +" Use `[g` and `]g` to navigate diagnostics +" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list +nmap <silent> [g <Plug>(coc-diagnostic-prev) +nmap <silent> ]g <Plug>(coc-diagnostic-next) + +" GoTo code navigation +nmap <silent> gd <Plug>(coc-definition) +nmap <silent> gy <Plug>(coc-type-definition) +nmap <silent> gi <Plug>(coc-implementation) +nmap <silent> gr <Plug>(coc-references) + +" Use K to show documentation in preview window +nnoremap <silent> K :call ShowDocumentation()<CR> + +function! ShowDocumentation() + if CocAction('hasProvider', 'hover') + call CocActionAsync('doHover') + else + call feedkeys('K', 'in') + endif +endfunction + +" Highlight the symbol and its references when holding the cursor +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming +nmap <leader>rn <Plug>(coc-rename) + +" Formatting selected code +xmap <leader>f <Plug>(coc-format-selected) +nmap <leader>f <Plug>(coc-format-selected) + +augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s) + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + +" Applying code actions to the selected code block +" Example: `<leader>aap` for current paragraph +xmap <leader>a <Plug>(coc-codeaction-selected) +nmap <leader>a <Plug>(coc-codeaction-selected) + +" Remap keys for applying code actions at the cursor position +nmap <leader>ac <Plug>(coc-codeaction-cursor) +" Remap keys for apply code actions affect whole buffer +nmap <leader>as <Plug>(coc-codeaction-source) +" Apply the most preferred quickfix action to fix diagnostic on the current line +nmap <leader>qf <Plug>(coc-fix-current) + +" Remap keys for applying refactor code actions +nmap <silent> <leader>re <Plug>(coc-codeaction-refactor) +xmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected) +nmap <silent> <leader>r <Plug>(coc-codeaction-refactor-selected) + +" Run the Code Lens action on the current line +nmap <leader>cl <Plug>(coc-codelens-action) + +" Map function and class text objects +" NOTE: Requires 'textDocument.documentSymbol' support from the language server +xmap if <Plug>(coc-funcobj-i) +omap if <Plug>(coc-funcobj-i) +xmap af <Plug>(coc-funcobj-a) +omap af <Plug>(coc-funcobj-a) +xmap ic <Plug>(coc-classobj-i) +omap ic <Plug>(coc-classobj-i) +xmap ac <Plug>(coc-classobj-a) +omap ac <Plug>(coc-classobj-a) + +" Remap <C-f> and <C-b> to scroll float windows/popups +if has('nvim-0.4.0') || has('patch-8.2.0750') + nnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" + nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" + inoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" + inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" + vnoremap <silent><nowait><expr> <C-f> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-f>" + vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" +endif + +" Use CTRL-S for selections ranges +" Requires 'textDocument/selectionRange' support of language server +nmap <silent> <C-s> <Plug>(coc-range-select) +xmap <silent> <C-s> <Plug>(coc-range-select) + +" Add `:Format` command to format current buffer +command! -nargs=0 Format :call CocActionAsync('format') + +" Add `:Fold` command to fold current buffer +command! -nargs=? Fold :call CocAction('fold', <f-args>) + +" Add `:OR` command for organize imports of the current buffer +command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') + +" Add (Neo)Vim's native statusline support +" NOTE: Please see `:h coc-status` for integrations with external plugins that +" provide custom statusline: lightline.vim, vim-airline +set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} + +" Mappings for CoCList +" Show all diagnostics +nnoremap <silent><nowait> <Leader>ca :<C-u>CocList diagnostics<cr> +" Manage extensions +nnoremap <silent><nowait> <Leader>ce :<C-u>CocList extensions<cr> +" Show commands +nnoremap <silent><nowait> <Leader>cc :<C-u>CocList commands<cr> +" Find symbol of current document +nnoremap <silent><nowait> <Leader>co :<C-u>CocList outline<cr> +" Search workspace symbols +nnoremap <silent><nowait> <Leader>cs :<C-u>CocList -I symbols<cr> +" Do default action for next item +nnoremap <silent><nowait> <Leader>cj :<C-u>CocNext<CR> +" Do default action for previous item +nnoremap <silent><nowait> <Leader>ck :<C-u>CocPrev<CR> +" Resume latest coc list +nnoremap <silent><nowait> <Leader>cp :<C-u>CocListResume<CR>
--- a/plugins/ctrlp Fri Oct 31 14:24:31 2025 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -" Ignored files/directories from autocomplete (and CtrlP) -set wildignore+=*/tmp/* -set wildignore+=*.so -set wildignore+=*.zip -set wildignore+=*/vendor/bundle/* -set wildignore+=*/node_modules/* -set wildignore+=*node_modules/* -set wildignore+=*/vendor/* -set wildignore+=*vendor/*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/ctrlp.vim Fri Nov 28 08:45:17 2025 -0500 @@ -0,0 +1,9 @@ +" Ignored files/directories from autocomplete (and CtrlP) +set wildignore+=*/tmp/* +set wildignore+=*.so +set wildignore+=*.zip +set wildignore+=*/vendor/bundle/* +set wildignore+=*/node_modules/* +set wildignore+=*node_modules/* +set wildignore+=*/vendor/* +set wildignore+=*vendor/*
--- a/plugins/nerdtree Fri Oct 31 14:24:31 2025 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -Plug 'preservim/nerdtree' - -nnoremap <leader>n :NERDTreeFocus<CR> -nnoremap <C-n> :NERDTree<CR> -nnoremap <C-t> :NERDTreeToggle<CR> - -" Start NERDTree and leave the cursor in it. -" autocmd VimEnter * NERDTree
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/nerdtree.vim Fri Nov 28 08:45:17 2025 -0500 @@ -0,0 +1,8 @@ +Plug 'preservim/nerdtree' + +nnoremap <leader>n :NERDTreeFocus<CR> +nnoremap <C-n> :NERDTree<CR> +nnoremap <C-t> :NERDTreeToggle<CR> + +" Start NERDTree and leave the cursor in it. +" autocmd VimEnter * NERDTree
--- a/plugins/taghelp Fri Oct 31 14:24:31 2025 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -autocmd BufRead,BufNewFile *.blade.php set filetype=blade - - -" autocmd FileType blade inoremap<buffer> > <c-r>=CreateTag()<cr> - - -" Abbreviations -autocmd FileType blade iabbr <silent> class= class=""<Left><C-R>=Eatchar('\s')<CR> -autocmd FileType blade iabbr <silent> id= id=""<Left><C-R>=Eatchar('\s')<CR> -autocmd FileType blade iabbr <silent> log console.log()<Left><C-R>=Eatchar('\s')<CR> - - - - -func Eatchar(pat) - let c = nr2char(getchar(0)) - return (c =~ a:pat) ? '' : c -endfunc - -func CreateTag() - let line = getline('.') - let end = col('.') - 1 - let begin = end - 1 - let start = '' - let tagname_regexp = '[a-zA-Z0-9-_\.#]' - let first_chars = '[a-zA-Z0-9]' - let id_regexp = '[#]' - let class_regexp = '[\.]' - let tagname = '' - let id = '' - let classes = '' - let current_type = 0 " 0: tagname, 1: classes, 2: id - " incase the previous character was not in the usage - if line[begin] !~ first_chars - return '>' - endif - - " reverse until we leave the replacement - while begin > 0 - if line[begin] !~ tagname_regexp - let begin += 1 - break - endif - let begin -= 1 - endwhile - - let start = begin - - " start over reading the tag name - while begin < end - "deteremine if the type changes - if line[begin] =~ id_regexp - let current_type = 2 - elseif line[begin] =~ class_regexp - let current_type = 1 - "need a space in the class if there is already classes - if classes != '' - let classes .= ' ' - endif - else - " Write to the current type - if current_type == 0 - let tagname .= line[begin] - elseif current_type == 1 - let classes .= line[begin] - elseif current_type == 2 - let id .= line[begin] - endif - endif - - let begin += 1 - endwhile - - " Trim the strings, just in case - let tagname = trim(tagname) - let id = trim(id) - let classes = trim(classes) - - - let str = '<' .tagname - if id != '' - let str .= ' id="' . id . '"' - endif - if classes != '' - let str .= ' class="' . classes . '"' - endif - let str .= '> </'. tagname . '>' - " delete the previous characters - let del_count = (end-start) - execute "normal! " . del_count . "X" - " delete the char under the cursor - execute "normal! x" - - return str . repeat("\<Left>", len(tagname) + 4) - -endfunc -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/taghelp.vim Fri Nov 28 08:45:17 2025 -0500 @@ -0,0 +1,97 @@ +autocmd BufRead,BufNewFile *.blade.php set filetype=blade + + +" autocmd FileType blade inoremap<buffer> > <c-r>=CreateTag()<cr> + + +" Abbreviations +autocmd FileType blade iabbr <silent> class= class=""<Left><C-R>=Eatchar('\s')<CR> +autocmd FileType blade iabbr <silent> id= id=""<Left><C-R>=Eatchar('\s')<CR> +autocmd FileType blade iabbr <silent> log console.log()<Left><C-R>=Eatchar('\s')<CR> + + + + +func Eatchar(pat) + let c = nr2char(getchar(0)) + return (c =~ a:pat) ? '' : c +endfunc + +func CreateTag() + let line = getline('.') + let end = col('.') - 1 + let begin = end - 1 + let start = '' + let tagname_regexp = '[a-zA-Z0-9-_\.#]' + let first_chars = '[a-zA-Z0-9]' + let id_regexp = '[#]' + let class_regexp = '[\.]' + let tagname = '' + let id = '' + let classes = '' + let current_type = 0 " 0: tagname, 1: classes, 2: id + " incase the previous character was not in the usage + if line[begin] !~ first_chars + return '>' + endif + + " reverse until we leave the replacement + while begin > 0 + if line[begin] !~ tagname_regexp + let begin += 1 + break + endif + let begin -= 1 + endwhile + + let start = begin + + " start over reading the tag name + while begin < end + "deteremine if the type changes + if line[begin] =~ id_regexp + let current_type = 2 + elseif line[begin] =~ class_regexp + let current_type = 1 + "need a space in the class if there is already classes + if classes != '' + let classes .= ' ' + endif + else + " Write to the current type + if current_type == 0 + let tagname .= line[begin] + elseif current_type == 1 + let classes .= line[begin] + elseif current_type == 2 + let id .= line[begin] + endif + endif + + let begin += 1 + endwhile + + " Trim the strings, just in case + let tagname = trim(tagname) + let id = trim(id) + let classes = trim(classes) + + + let str = '<' .tagname + if id != '' + let str .= ' id="' . id . '"' + endif + if classes != '' + let str .= ' class="' . classes . '"' + endif + let str .= '> </'. tagname . '>' + " delete the previous characters + let del_count = (end-start) + execute "normal! " . del_count . "X" + " delete the char under the cursor + execute "normal! x" + + return str . repeat("\<Left>", len(tagname) + 4) + +endfunc +
