Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I yank (copy) around a block comment in vim?

One of my favorite things about vi(m)'s yank (i.e. copy) syntax is the ability to copy the entire contents of the current word, line, parens, code block, etc. using the ya{something} and yi{something} syntaxes

Examples for reference:

  • word: yaw
  • parens: ya(
  • curly braces (without the braces): yi{
  • XML/HTML tag: yat

So what I'm trying to figure out now is whether vim recognizes block comments as a yankable unit. I'm imagining something like yac. Is this standard? If not, is there a plugin or a mapping that someone's figured out?

like image 998
Ken Bellows Avatar asked Dec 06 '25 05:12

Ken Bellows


1 Answers

You can, if you install a plugin, for example: https://github.com/glts/vim-textobj-comment

like image 139
VanLaser Avatar answered Dec 08 '25 10:12

VanLaser



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!