Могут ли некоторые из ваших зависимостей быть статически связаны?
You can use a combination of matching XML tags, as can be seen in this question and Perl's search and replace.
For instance, given this snippet:
<TypeDef name="a">
<ArrayType high="14" low="0">
<UndefType type="node">
</UndefType>
</ArrayType>
</TypeDef>
Put the cursor on either the opening or closing TypeDef
and type the following sequence:
vat:s/^\(.*\)$/<!--\1-->/
v
- puts you into visual mode
at
- selects the whole XML tag
:s/^\(.*\)$//
- surrounds each line with ''
, the comment delimiters for XML
Alternatively, you can just delete it like this:
dat
d
- delete according to the following movements
at
- as before
Vim doesn't have smart commenting for all file types by itself. You should get a script for your commenting needs.
I use the enhcomentify script which has been around and maintained for a long time
http://www.vim.org/scripts/script.php?script_id=23
It seems to do xml well and you get the advantage of the same key bindings for any filetype you are using.
There are others.. notably the NERD Commenter
Best it'd be if you'd find a command that adds things in the beginning and end of the selection.
When I'm commenting python code, I'm doing this:
:2,4s/^/#/g
используйте Surround.vim для общего сопоставления тегов, удаления, вставки, окружения и т. Д.
Для комментирования тегов легко использовать текстовые объекты vim и простой макрос
Пример:
введите
vmap ,c <esc>a--><esc>'<i<!--<esc>'>$
в подходящее место, затем поместите курсор на заглавную букву «A» в «ArrayType» во второй строке следующего (заимствовано из приведенного выше примера Натана Фельмана)
<TypeDef name="a">
<ArrayType high="14" low="0">
<UndefType type="node">
</UndefType>
</ArrayType>
</TypeDef>
, затем нажмите
vat,c
и вы получите:
<TypeDef name="a">
<!--<ArrayType high="14" low="0">
<UndefType type="node">
</UndefType>
</ArrayType>-->
</TypeDef>
с курсором в конце комментария
Я думаю, что адаптация этой подсказки vim может быть полезной.
Я предлагаю добавить:
" Wrap visual selection in an XML comment
vmap <Leader>c <Esc>:call CommentWrap()<CR>
function! CommentWrap()
normal `>
if &selection == 'exclusive'
exe "normal i-->"
else
exe "normal a-->"
endif
normal `<
exe "normal i<!--"
normal `<
endfunction
в ваш .vimrc
Затем с визуальным выделением active (V), нажмите \ c (обратная косая черта, затем c), чтобы заключить блок в
комментарии в стиле XML.
В качестве альтернативы, как предложено в вики, вы можете поместить код в ~ / .vim / scripts / wrapwithcomment.vim и добавьте в свой .vimrc:
au Filetype html,xml source ~/.vim/scripts/wrapwithcomment.vim
, чтобы эта функция загружалась только при работе с файлом html или xml.