IttayD
IttayD

Reputation: 29123

vim: how to type colon character in normal mode?

I'm using surround.vim and want to yank text between : (in a PATH expression). When I type ys:, it goes into command-line mode. How can I prevent that?

Upvotes: 0

Views: 2505

Answers (1)

romainl
romainl

Reputation: 196516

You have got everything wrong:

  • surround has nothing to do with yanking,
  • yanking between common pairs of characters (()""''{}[]<>) is done with built-in text-objects like i( or a<,
  • surround indeed works on text-objects but there's no built-in text-object for colons so:

    1. you can't do ys: because : is not a text-oject or even a motion,
    2. you can't do ysi: either for the same reason,
    3. And none of that will help you yank anyway.

If you want to yank between surrounding colons, you basically have three possibilities. Ordered by complexity:

  • T:yt: which you could map to yi: if you want
  • use a plugin that allows you to define your own text-objects, there are a few,
  • create your own custom text-objects.

Upvotes: 3

Related Questions