0

I often need to edit huge .yaml files, where I need to delete entire maps or arrays.

My current approach is to go into visual (line-wise) mode (Shift + V) and mark the lines manually, but that feels cumbersome compared to editing HTML tags in Vim (e.g. dit)

How can I efficiently delete .yaml elements in Vim?

enter image description here

1
3

Another great use of indent-object: I believe dii or one of the other maps would do it here.

5
  • Thanks, I assume there is no Vim native way then, which I would have anticipated, since I often need such functionality on remote systems. Can you describe how to install indent-object as a Vim package? I don't use vim-plug and have no intention to install it.
    – Shuzheng
    Sep 26 at 17:27
  • As a package, you just put the source (or submodule or whatever you want) in ~/.vim/pack/<some arbitrary name>/start/indent-object @Shuzheng
    – D. Ben Knoble
    Sep 26 at 17:57
  • Thanks. By "submodule" you mean git submodule?
    – Shuzheng
    Sep 26 at 18:01
  • Yes; I use git to track files like this so I use submodules to manage packages.
    – D. Ben Knoble
    Sep 26 at 18:01
  • indent-object seems to work very well with .yaml maps, but it fails for arrays, i.e. it's not possible to remove a single array element etc., since indentation for arrays is the same as for the surrounding map
    – Shuzheng
    Sep 26 at 18:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.