26

I want to have the reverse of

  • Ctrl+O

to be

  • Shift+Ctrl+O

The original reverse is

  • Ctrl+I

How can you remap the reverse of CTRL+O in Vim to be Shift+CTRL+O?

Fabrizio
  • 7,603
  • 6
  • 44
  • 104
Léo Léopold Hertz 준영
  • 134,464
  • 179
  • 445
  • 697

4 Answers4

63

As shown in help under

:help C-o

the "reverse" of Ctrl+o is

Ctrl+i or Tab

Kevin Tindall
  • 375
  • 5
  • 16
Rook
  • 60,248
  • 49
  • 165
  • 242
  • @Idigas: How can you remap the key to Shift-Ctrl-O. I cannot ever remember the C-i. – Léo Léopold Hertz 준영 May 09 '09 at 17:32
  • @Ruslan `Ctrl-i` and `Ctrl-I` are synonymous – törzsmókus Oct 31 '19 at 19:31
  • @törzsmókus no they are not. `Ctrl-I` is equivalent to `Ctrl-Shift-i`. And it doesn't really work to undo `Ctrl-o`, unlike `Ctrl-i`, which does. – Ruslan Oct 31 '19 at 19:57
  • On most terminals, you (or vim) have no way to tell whether the user pressed `Ctrl-i` or `Ctrl-Shift-i`, that's what I meant by ‘synonymous’. See the link in [Andy's answer](https://stackoverflow.com/a/852657/501765) for explanation – törzsmókus Nov 01 '19 at 06:14
11

Unfortunately Vim recognises Control-o and Control-O as synonyms.
There's some information here about why you can't map Control-Shift-o, but it doesn't look like it's possible.

I've upvoted Idigas answer, it's not that hard to remember Control-I.

Andy
  • 3,794
  • 24
  • 28
4

Actually, if you use xterm, you can get around the terminal emulator limitations by remapping keys in your .Xresources file. Use a key sequence that you do not use anyway, for instance C-M-7 (0x9f):

XTerm*vt100*translations: #override\n\
    Ctrl Shift <Key> O: string(0x9f)

Then do an xrdb -merge ~/.Xresources and map C-M-7 to C-i in Vim.

Admittedly it's a hack, but it have helped me a lot. Check out my .Xresources for inspiration.

mntnoe
  • 154
  • 2
1

Vim sees Ctrl+Shift+O as Ctrl+O because of a limitation with terminal emulators.

Fabrizio
  • 7,603
  • 6
  • 44
  • 104
graywh
  • 9,640
  • 2
  • 29
  • 27