2

Are there simple tweaks that I can visual select everything with in a pair of fold markers? Just like what vi" will do for a pair of double quotes. Preferably vi plus some other keys.

  • Not the neatest but zc to close the fold then yy will yank the fold contents. If your foldmethod is marker it will select the markers as well – Steve Oct 16 '18 at 3:02
  • 2
    There is an example for a fold text object in the wiki – Christian Brabandt Oct 16 '18 at 7:55
3

What you are looking for is called a "text-object" in Vim terminology and you can find the list of these text-objects at :h text-objects. As you can see there is not a built-in text-object for the folds.

However you might be interested in this plugin: vim-textobj-user. It allows you to define your own text-objects easily.

Note that if you don't want to use a plugin you can simply use an operator pending mode mapping (see :h omap-info).

  • You will find in the wiki of vim-textobj-user the plugin vim-textobj-fold which defines iz and az for you. However, I would have expected that iz does not select the fold markers. But it does. The difference is described in the docs. Luckily, there is a pull request and a fork which modify iz to ignore fold marker lines: kana/vim-textobj-fold/pull/8 and somini/vim-textobj-fold – Hotschke Oct 21 '18 at 6:20

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.