Vim Tips Wiki
(Change to TipImported template + severe manual clean)
(Mentioned "noremap!" instead of "inoremap")
 
(9 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
|id=1323
 
|id=1323
 
|previous=1322
 
|previous=1322
|next=1324
+
|next=1326
 
|created=September 7, 2006
 
|created=September 7, 2006
 
|complexity=basic
 
|complexity=basic
Line 9: Line 9:
 
|version=5.7
 
|version=5.7
 
|rating=19/28
 
|rating=19/28
  +
|category1=
  +
|category2=
 
}}
 
}}
In many languages you will use '!@#$%^&*()_' far more often than you use '1234567890-' so you will find yourself pressing SHIFT quite often, but this is not necessary. You can reverse the function of the number row keys so that typing a number key gives you the symbol instead of the number, and SHIFT-Number-Key can be used to type the number. This will save you alot of time leaning on the SHIFT key, especially for '(' and ')' and '_', which are more common than their non-SHIFT characters '9' and '0' and '-'.
+
In many languages you will use '!@#$%^&*()_' far more often than you use '1234567890-' so you will find yourself pressing SHIFT quite often, but this is not necessary. You can reverse the function of the number row keys so that typing a number key gives you the symbol instead of the number, and SHIFT-Number-Key can be used to type the number. This will save you a lot of time leaning on the SHIFT key, especially for '(' and ')' and '_', which are more common than their non-SHIFT characters '9' and '0' and '-'.
 
Just add these commands to your vimrc:
 
   
 
Just add these commands to your [[vimrc]]
 
<pre>
 
<pre>
 
" map each number to its shift-key character
 
" map each number to its shift-key character
Line 22: Line 23:
 
inoremap 5 %
 
inoremap 5 %
 
inoremap 6 ^
 
inoremap 6 ^
inoremap 7 &amp;
+
inoremap 7 &
 
inoremap 8 *
 
inoremap 8 *
 
inoremap 9 (
 
inoremap 9 (
Line 34: Line 35:
 
inoremap % 5
 
inoremap % 5
 
inoremap ^ 6
 
inoremap ^ 6
inoremap &amp; 7
+
inoremap & 7
 
inoremap * 8
 
inoremap * 8
 
inoremap ( 9
 
inoremap ( 9
Line 53: Line 54:
 
----
 
----
 
I tried putting this in my .vimrc, but then went back and pulled it out when I realized a flaw. The change only applies within the Vim buffer. Once I got to the command line (for example, entering ":q!", what I actually entered was ":q1") since the remapping did not extend outside the Vim buffer.
 
I tried putting this in my .vimrc, but then went back and pulled it out when I realized a flaw. The change only applies within the Vim buffer. Once I got to the command line (for example, entering ":q!", what I actually entered was ":q1") since the remapping did not extend outside the Vim buffer.
  +
----
  +
I don't use this tip, but you can replace each "inoremap" with "noremap!" to have the mapping apply in insert mode as well as command mode.
  +
  +
----
  +
Well, if you're brave you could do it system-wide:
  +
<pre>
  +
xmodmap - <<EOF
  +
keycode 10 = 1 exclamdown onesuperior exclamdown onesuperior
  +
keycode 11 = 2 quotedbl at twosuperior at twosuperior
  +
keycode 12 = 3 numbersign sterling threesuperior sterling threesuperior
  +
keycode 13 = 4 dollar
  +
keycode 14 = percent 5 onehalf cent onehalf cent
  +
keycode 15 = ampersand 6 yen fiveeighths yen fiveeighths
  +
keycode 16 = slash 7 braceleft division braceleft division
  +
keycode 17 = parenleft 8 bracketleft guillemotleft bracketleft guillemotleft
  +
keycode 18 = parenright 9 bracketright guillemotright bracketright guillemotright
  +
keycode 19 = 0 equal braceright degree braceright degree
  +
EOF
  +
</pre>
  +
This is what I'm experimenting with now. Since I actually use at least 1,2,3 fairly often, only swapped half the row ^^ Not sure how it'll work out though
  +
  +
----
  +
This tip is for US-QWERTY only. Other "national keyboards" have different symbols on the number keys, and some have the numbers "shifted" with punctuation marks and/or accented letters on the "unshifted" side of the same keys &#8212; my fr-BE is an example, but fr-FR, though also an AZERTY keyboard, has different symbols on the "unshifted" digits.
   
  +
Of course, the inoremaps at top can be adapted ''mutatis mutandis'' to any keyboard which has "unshifted" digits (those with "shifted" digits don't need them); it's much less obvious what regards the xmodmap solution, because of the esoteric key names &#8212; and also, of course, it works for X11 but not for Windows, and I don't know about the Mac. &#8212; [[User:Tonymec|Tonymec]] 23:47, 25 May 2009 (UTC)
 
----
 
----

Latest revision as of 18:57, 12 February 2014

Tip 1323 Printable Monobook Previous Next

created September 7, 2006 · complexity basic · author Peter Hodge · version 5.7


In many languages you will use '!@#$%^&*()_' far more often than you use '1234567890-' so you will find yourself pressing SHIFT quite often, but this is not necessary. You can reverse the function of the number row keys so that typing a number key gives you the symbol instead of the number, and SHIFT-Number-Key can be used to type the number. This will save you a lot of time leaning on the SHIFT key, especially for '(' and ')' and '_', which are more common than their non-SHIFT characters '9' and '0' and '-'.

Just add these commands to your vimrc

" map each number to its shift-key character
inoremap 1 !
inoremap 2 @
inoremap 3 #
inoremap 4 $
inoremap 5 %
inoremap 6 ^
inoremap 7 &
inoremap 8 *
inoremap 9 (
inoremap 0 )
inoremap - _
" and then the opposite
inoremap ! 1
inoremap @ 2
inoremap # 3
inoremap $ 4
inoremap % 5
inoremap ^ 6
inoremap & 7
inoremap * 8
inoremap ( 9
inoremap ) 0
inoremap _ -

This is very frustrating for the first month or two when you will frequently press SHIFT when you don't need to, or forget to press SHIFT when you do. After a few months your typing speed should be noticeably faster and more relaxed as you are no longer holding the SHIFT key down all day.

Comments[]

This tip could make you quite crazy if you use other programs, say Word. Other than that, it would be very cool typing parenthesis without pressing shift!


If you are used to typing numbers on the numpad with NumLock on, just map each number to its shift-key character, leaving shift-number keys as is.

This way, you can keep typing shift-key characters with Shift, until you get used to the new easiest typing style.


I tried putting this in my .vimrc, but then went back and pulled it out when I realized a flaw. The change only applies within the Vim buffer. Once I got to the command line (for example, entering ":q!", what I actually entered was ":q1") since the remapping did not extend outside the Vim buffer.


I don't use this tip, but you can replace each "inoremap" with "noremap!" to have the mapping apply in insert mode as well as command mode.


Well, if you're brave you could do it system-wide:

xmodmap - <<EOF
keycode  10 = 1 exclamdown onesuperior exclamdown onesuperior
keycode  11 = 2 quotedbl at twosuperior at twosuperior
keycode  12 = 3 numbersign sterling threesuperior sterling threesuperior
keycode  13 = 4 dollar
keycode  14 = percent 5 onehalf cent onehalf cent
keycode  15 = ampersand 6 yen fiveeighths yen fiveeighths
keycode  16 = slash 7 braceleft division braceleft division
keycode  17 = parenleft 8 bracketleft guillemotleft bracketleft guillemotleft
keycode  18 = parenright 9 bracketright guillemotright bracketright guillemotright
keycode  19 = 0 equal braceright degree braceright degree
EOF

This is what I'm experimenting with now. Since I actually use at least 1,2,3 fairly often, only swapped half the row ^^ Not sure how it'll work out though


This tip is for US-QWERTY only. Other "national keyboards" have different symbols on the number keys, and some have the numbers "shifted" with punctuation marks and/or accented letters on the "unshifted" side of the same keys — my fr-BE is an example, but fr-FR, though also an AZERTY keyboard, has different symbols on the "unshifted" digits.

Of course, the inoremaps at top can be adapted mutatis mutandis to any keyboard which has "unshifted" digits (those with "shifted" digits don't need them); it's much less obvious what regards the xmodmap solution, because of the esoteric key names — and also, of course, it works for X11 but not for Windows, and I don't know about the Mac. — Tonymec 23:47, 25 May 2009 (UTC)