2

Vim/vi shortcuts are awesome, but there is one behavior that I would be very happy if it could be configured. My machine uses Brazilian Portuguese(abnt2) keyboard map,and some accents(like caret) needs an extra spacebar to be print, obviously because they wait/expect another character, mostly vowels. Example of the "cut until you find an empty line":

  d/^$

Keystrokes actually needed on br-abnt2:

  d / <shift + ~ , spacebar>(to result ^) $ <enter>

I could use { d } as it is explained on this awesome thread, but i would benefit much more on other accents(backslash) where the extra backspace trick is needed, and most important, without change my keyboard mapping to "US" for example.

Edit: I also know that this is a keymap limitation, since our language expect something after the accent, and this is why i'm asking if there is a way to circunvent this limitation inside vim.

Any ideas?

Community
  • 1
  • 1
  • The space bar is not the problem, here: it's the thing that allows you to insert what is essentially a "non-character". Usually, hitting two times on `^` is enough. – romainl Apr 01 '13 at 19:03
  • Try prefixing with v to escape the next character. – Jim Stewart Apr 01 '13 at 19:04
  • Yeah. I know that this is a keymap limitation, and the space is just the thing I USE to insert the caret without a vowel. And that is why i was poking arround, to see if there is a way to circunvent the keymaping limitations inside vim ;) –  Apr 02 '13 at 11:00

1 Answers1

1

The problem does not come from the editor, but your keymap. In fact, the caret is set to be a "dead key". Meaning that it should wait for other input before being printed.

What you probably need is a new keymap that has the caret as a non dead-key. As for example, uk-gb map has caret on the key as well as another dead-key ( if I remember correctly).

If you don't want/can't remap your keyboard, you can use vim mapping function do act so. Just choose an unused key and map it like this:

imap g ^

This will insert ^ while typing g on insert mode (other mapping for other- mode exists, nmap, ...). For example, to use the vim mapping in the vim command-line, you shall use :

cmap g ^

Then your example will be working.

M'vy
  • 5,696
  • 2
  • 30
  • 43
  • Yeah. I know that the problem is with my keyboard layout, the same way i would be happy to find a solution that could change the "dead key behavior" of caret, the same way i don't need to change my keymap. Your answer is pretty usefull on insert mode, but will not work under "movements" like explained above :( - Thanks for your tip :) –  Apr 02 '13 at 10:58
  • Actually `nmap ' ^` does work on movements. It may be somehow unresponsible on the different other keys depending on the existing other shortcut beginning with this key (example g). Check them out with `:map `. – M'vy Apr 02 '13 at 11:52
  • Oh, my bad, it does not work with your example. I'll check if other mappings work. – M'vy Apr 02 '13 at 11:54
  • Wow. That worker like a charm, Kudos for you. Now i will map any key that is "unused" to ^ - d/g$ :) –  Apr 02 '13 at 14:27