Delete text in between HTML tags in vim?

后端 未结 5 2156
暗喜
暗喜 2020-12-22 15:12

I know

di<

will delete in an HTML tag itself.

Is there an easy way to delete text in between two tags?



        
相关标签:
5条回答
  • 2020-12-22 15:57

    dit will delete the text between matching XML tags. (it is for "inner tag block".)

    See :h it and :h tag-blocks.

    0 讨论(0)
  • 2020-12-22 16:08

    If you're aiming to do the inverse of deleting text between flags, I suggest installing Vim-Surround and running dst which deletes the surround tag

    0 讨论(0)
  • 2020-12-22 16:10
    cit
    ci"
    

    Two of the best productivity enabler commands of vim.

    I save a lot of time and effort with just those two.

    0 讨论(0)
  • 2020-12-22 16:11

    try dt< while the cursor is on the first character to delete. In your example the 'H'.

    0 讨论(0)
  • 2020-12-22 16:13

    (cursor on first character to delete) v/<[enter]d

    This solution starts on the first character, then enters visual mode ("v"). It then searches for the next start bracket ("/<"), and then press enter to exit the search.

    At this point, your visual selection will cover the text to delete. press d ("d") to delete it.

    If I had to do this for a bunch of tags, I'd record the command and combine it with some other searches to make it repeatable. The key sequence might look like this:

    [cursor on start of file] qa/>[enter]lv/<[enter]dnq

    then press:

    20@a

    to do this for 20 tags

    0 讨论(0)
提交回复
热议问题