tpope / vim-surround

surround.vim: Delete/change/add parentheses/quotes/XML-tags/much more with ease
https://www.vim.org/scripts/script.php?script_id=1697
13.43k stars 446 forks source link

How to surround highlighted text? #306

Open zer09 opened 4 years ago

zer09 commented 4 years ago

Example I have this

const textToBeHighlighted = text[tobehighlighted];

how to surround the text text[tobehighlighted]?

Then the output would be like this.

const textToBeHighlighted = Number(text[tobehighlighted]);

Thanks

scebotari66 commented 4 years ago
const textToBeHighlighted = *text[tobehighlighted];

In normal mode, with the cursor on *, you can do yst;fNumber<cr> or vt;SfNumber<cr>.

Also check the docs. You can find more examples there that in README.

pkfm commented 4 years ago

use the g_ motion to select up through the last non-blank character on the line instead of t; for non colon terminated lines.