This is a mostly comprehensive rearrangement of Vim's key mappings, to be more spatially ordered and modernised. It reassigns almost all normal, visual, and insert mode keys. The principles are to: group related commands on nearby keys; select the most important commands for the best positions; adopt some common standards from outside.
The design idea is based on the ErgoEmacs Keybinding (http://xahlee.org/emacs/ergonomic_emacs_keybinding.html), but completely Vim-ified.
This is the first version, and open to adjustment. For Vim Version 7.2, and US-like keyboards.
Probably the first thing one learns in Vim is the cursor movement keys. One of the principles, and virtues, of Vim is clear straight away: put the commands right under the fingers. Yet when you put your fingers on the keyboard you find something wrong: the commands are not under your fingers after all, but off by one to the left! Oh.
Would it not be better if the movement keys were i,j,k,l – making the familiar ‘inverted-t’ shape? Almost completely. The only problem is the inertia of convention – which accreted around rules now obsolete. But if you are a new user of Vim there is no need to be constrained by that. And from this change follows the rest.
The single major deficiency is that the help files are not updated to match. But it is easy to look up the original commands in the new reference list, or search the reference list for original commands.
Spatial grouping is a simple and flexible way to create order, and order enables understanding, learning, and memory. Each set of related keys forms a higher-level module: learning each key strengthens learning the others, and the abstraction allows a choice of members. Alternative orderings are weaker. Choosing commands by mnemonic letters overconstrains the layout, and will be either incomplete or arbitrarily forced. Reusing established conventions and patterns will be incomplete, and for Vim the bases are now forgotten.
The principles are:
Not everything is changed; in normal mode:
Mainly for normal mode, but echoed in other modes.
Tab and pane group, edit group, movement group.
Unmodified in bold, shift in italic, control in small-caps.
` recording execute record |
! filter lines ext |
@ open Mr |
# open tab with file |
$ open tab with search |
% split pane |
^ close others pane |
& above pane |
* below pane |
( prev sentence |
) next sentence |
- jump back |
= filter lines ext |
back |
tab | Q repeat last edit cmd-line |
W switch case char motion (window prefix) |
E indent outdent incr num |
R word cut change del |
T char cut change |
Y matching item older edit pos newer edit pos |
U left word with punct word end |
I up page up scroll up |
O right word with punct word end |
P end end para |
[ move etc. move etc. |
] move etc. move etc. |
\ |
capslock | A visual mode line block |
S insert home insert line over create line over |
D insert end insert line under create line under |
F insert before after replace |
G (g prefix) |
H home non-blank home home para |
J left screen top buff top |
K down page down scroll down |
L right screen bot buff bot |
; command line open CL pane (twice for search) |
' use register |
return | |
shift | Z undo redo show undo list |
X cut change del |
C copy append to a |
V paste before after |
B (z prefix) |
N search again backward unhilight |
M next occurence prev repeat last |
, search grabbed partial backward |
. search grabbed backward |
/ search backward |
shift | ||
ctrl | space go to mark mark a position set prev context mark |
ctrl |
` | ! filter lines |
@ open Mr |
# open tab with file |
$ open tab with search |
% split pane |
^ close others pane |
& above pane |
* below pane |
( prev sentence |
) next sentence |
- | = filter lines |
back |
tab | Q | W switch case |
E indent outdent num seq |
R | T replace repeated |
Y matching item last edit pos column |
U left word with punct word end |
I up page scroll |
O right word with punct word end |
P end last para |
[ move etc. move etc. |
] move etc. move etc. |
| exchange cursor position 2 |
capslock | A visual mode line block |
S block insert block append |
D i text object |
F a text object |
G (g prefix) |
H home non-blank home home para |
J left screen top buff top |
K down page scroll |
L right screen bot buff bot |
; command line for selected |
" exchange cursor position 1 |
return | |
shift | Z | X cut change del |
C copy append to a |
V paste over and copy |
B (z prefix) |
N search again backward unhilight |
M next occurence prev repeat last |
, search grabbed partial backward |
. search grabbed backward |
/ search selected backward |
shift | ||
ctrl | space | ctrl |
` | ! | @ paste previous, exit |
# | $ | % | ^ | & | * | ( | ) | - to last position |
= | back |
tab | Q paste previous |
W del word backward |
E copy char below |
R copy char above |
T | Y to last position edited |
U |
I tab |
O |
P |
[ exit insert |
] abort insert |
\ |
capslock | A abbrev trigger |
S |
D keyword completion next |
F command and return to insert |
G (g prefix) |
H |
J |
K |
L |
; |
' |
return ctrl-x sub-mode |
|
shift | Z delete all inserted |
X | C | V paste |
B start new undoable edit |
N |
M return |
, |
. |
/ |
shift | ||
ctrl | space | ctrl |
Annotated list of mappings.
@ | open Mr | [:Mr ] |
# | open tab with filename | [:tabedit ] |
£ | open tab with filename | [:tabedit ] |
$ | open tab with searched filename | [:tabfind ] |
% | split pane | [:spl ] |
^ | close other panes | [ctrl-w o ] |
(n)& | go to above wrapped pane, or (n)th pane | [ctrl-w shft-w ] |
(n)* | go to below wrapped pane, or (n)th pane | [ctrl-w ctrl-w ] |
(n)( | to prev sentence | [( ] |
(n)) | to next sentence | [) ] |
0 | update buffer | [:up<CR> ] |
(n)- | jump back, (n) times | [ctrl-o ] |
(n)_ | jump fore, (n) times | [ctrl-i ] |
=(motion) | filter (motion) lines through'equalprg' | [leave unchanged ] |
+ | unmap |
(n)q | repeat last insertion or editing command, updating (n) | [. ] |
(n)shft-q | repeat last command-line, (n) times | [@: ] |
ctrl-q | unmap | |
(n)w | switch case of char and move left, (n) times | [~ ] |
shft-w(motion) | switch case to position of motion | [g~ ] |
ctrl-w | [leave unchanged] | |
(n)e | indent (n) lines | [>> ] |
(n)shft-e | outdent (n) lines | [<< ] |
ctrl-e | increment number | [<C-a> ] |
(reg)r | cut a word | [daw ] |
(reg)shft-r | cut i word, then insert | [ciw ] |
ctrl-r | del a word | ["_daw ] |
(n)(reg)t | cut char foreward, (n) times | [x ] |
(n)shft-t(char) | replace/overwrite char, (n) times | [r ] |
ctrl-t | unmap |
a | visual, char oriented | [v ] |
shft-a | visual, line oriented | [shft-v ] |
ctrl-a | visual, block oriented | [ctrl-v ] |
(n)s | insert, at home non-blank, (n) times | [g^i ] |
(n)shft-s | create new line over, then insert, (n) times | [shft-o ] |
(n)ctrl-s | create new line over, (n) times | [shft-o esc ] |
(n)d | insert, at end, (n) times | [g$a ] |
(n)shft-d | create new line under, then insert, (n) times | [o ] |
(n)ctrl-d | create new line under, (n) times | [o esc ] |
(n)f | insert, before position, (n) times | [i ] |
(n)shft-f | insert, after position, (n) times (append) | [a ] |
(n)ctrl-f | replace: insert in overwrite mode, (n)-1 times | [shft-r ] |
g | [leave unchanged] | |
shft-g | unmap | |
ctrl-g | unmap |
(n)z | undo, (n) times | [u ] |
(n)shft-z | redo, (n) times | [ctrl-r ] |
ctrl-z | show undo list | [:undolist<CR> ] |
(reg)x(motion) | cut to position of motion | [d ] |
(reg)shft-x(motion) | cut to position of motion, then insert | [c ] |
ctrl-x(motion) | del to position of motion | ["_d ] |
(reg)c(motion) | copy to position of motion | [y ] |
shft-c(motion) | append to reg a | ["Ay ] |
shft-c shft-c | append line to reg a | ["Ayy ] |
ctrl-c | interrupt | [leave unchanged ] |
(n)(reg)v | paste to position before, (n) times | [shft-p ] |
(n)(reg)shft-v | paste to position after, (n) times | [p ] |
ctrl-v | unmap | |
(n)(reg)xx | cut line, (n) times | [dd ] |
(n)(reg)shft-xx | cut line, (n) times, then insert | [cc ] |
(n)(reg)ctrl-xx | del line, (n) times | ["_ dd ] |
(n)(reg)cc | copy line, (n) times | [yy ] |
d(char) | select 'inner' text object | [i ] |
f(char) | select 'a' text object | [a ] |
y | to matching paren/bracket/brace/comment/etc | [% ] |
shft-y | to older edit position | [g; ] |
(n)ctrl-y | to newer edit position | [g, ] |
(n)u | word left start, ignore punctuation, (n) times | [shft-b ] |
(n)shft-u | word left start, (n) times | [b ] |
(n)ctrl-u | word left end, ignore punctuation, (n) times | [gE ] |
(n)i | up (screen line), (n) times | [gk ] |
(n)shft-i | scroll page up, (n) times | [ctrl-b ] |
(n)ctrl-i | scroll line up, (n) times | [ctrl-y ] |
(n)o | word right start, ignore punctuation, (n) times | [shft-w ] |
(n)shft-o | word right start, (n) times | [w ] |
(n)ctrl-o | word right end, ignore punctuation, (n) times | [shft-e ] |
(n)p | end, (n) lines down | [g$ ] |
(n)shft-p | end, (n) lines down | [g$ ] |
(n)ctrl-p | end para, (n) lines down | [$ ] |
h | home, non-blank | [g^ ] |
shft-h | home | [g0 ] |
ctrl-h | home para, non-blank | [^ ] |
(n)j | left, (n) times | [h ] |
(n)shft-j | screen top, or (n) lines from | [shft-h ] |
(n)ctrl-j | buffer top, or (n) lines from | [gg ] |
(n)k | down (screen line), (n) times | [gj ] |
(n)shft-k | scroll page down, (n) times | [ctrl-f ] |
(n)ctrl-k | scroll line down, (n) times | [ctrl-e ] |
(n)l | right, (n) times | [l ] |
(n)shft-l | screen bottom, or (n) lines from | [shft-l ] |
ctrl-l | buffer bottom | [shft-g ] |
: | open command history pane | [q: ] |
:: | open search history pane | [q/ ] |
; | command-line mode | [: ] |
' | use reg | [" ] |
" | use reg | [leave unchanged ] |
\ | [leave unchanged] | |
| | unmap |
(n)n | search again, (n) times | [leave unchanged ] |
(n)shft-n | search again, in opposite direction, (n) times | [leave unchanged ] |
ctrl-n | stop highlighting search | [:nohlsearch<CR> ] |
(n)m(char) | to next occurence of (char), (n) times | [f ] |
(n)shft-m(char) | to previous occurence of (char), (n) times | [F ] |
(n)ctrl-m | repeat last m command, (n) times | [; ] |
(n), | to fore occurence of grabbed word, partial match, (n) times | [g* ] |
(n)< | to back occurence of grabbed word, partial match, (n) times | [g# ] |
(n). | to fore occurence of grabbed word, (n) times | [* ] |
(n)> | to back occurence of grabbed word, (n) times | [# ] |
(n)/(pattern) | search foreward for pattern, (n) times | [leave unchanged ] |
(n)?(pattern) | search backward for pattern, (n) times | [leave unchanged ] |
~(reg) | record series of commands to (alpha/numeric char register) | [q ] |
~ | end recording | [q ] |
(n)`(reg) | execute (reg), (n) times | [@ ] |
(n)`` | repeat prev `, (n) times | [@@ ] |
shft-<Space>(letter) | mark a position (letter is case-sensitive) | [m ] |
ctrl-<Space> | set previous context mark | [m` ] |
<Space>(letter) | return to marked position (col and row) | [` ] |
<Space><Space> | return to last position (col and row) | [`` ] |
(n)<BS> | del char backward, (n) times | ["_shft-x ] |
(n)shft-<BS> | del word backward, (n) times | ["_db ] |
(n)<Del> | del char foreward, (n) times | ["_x ] |
(n)shft-<Del> | del word foreward, (n) times | ["_de ] |
<Home> | home screen line | [g0 ] |
<S-Home> | home para | [<Home> ] |
<C-Home> | start of file | [leave unchanged ] |
<End> | end screen line | [g$ ] |
<S-End> | end para | [<End> ] |
<C-End> | end of file | [leave unchanged ] |
<PageUp> | [leave unchanged] | |
<S-PageUp> | screen top | [<S-h> ] |
<C-PageUp> | prev tab | [leave unchanged ] |
<PageDown> | [leave unchanged] | |
<S-PageDown> | screen bottom | [<S-l> ] |
<C-PageDown> | next tab | [leave unchanged ] |
<C-S-PageUp> | move tab left | [:tabm-1<CR> ] |
<C-S-PageDown> | move tab right | [:tabm+1<CR> ] |
<Up> | [leave unchanged] | |
<S-Up> | up para | [<Up> ] |
<C-Up> | scroll line up | [ctrl-y ] |
<Down> | [leave unchanged] | |
<S-Down> | down para | [<Down> ] |
<C-Down> | scroll line down | [ctrl-e ] |
<Left> | [leave unchanged] | |
<S-Left> | word left start | [leave unchanged ] |
<C-Left> | word left start, ignore punctuation | [shft-b ] |
<Right> | [leave unchanged] | |
<S-Right> | word right start | [leave unchanged ] |
<C-Right> | word right start, ignore punctuation | [shft-w ] |
gm | go to first occurence in current function of grabbed token | [gd ] |
g shft-m | go to first occurence of grabbed token | [gD ] |
(n)gj | join lines | [shft-j ] |
(n)g shft-j | join lines (no space inserts) | [g shft-j ] |
g: | open commandline history window (ctrl-c to exit) | [q: ] |
g/ | open search history window (ctrl-c to exit) | [q/ ] |
!(motion)(command)<CR> | filter lines covered by motion through command | [leave unchanged ] |
(n)!!(command)<CR> | filter (n) lines through command | [leave unchanged ] |
b | z-prefix | [z] |
shft-b | unmap | |
ctrl-b | unmap | |
<F2> | toggle read-only and no-modify | [:set ro! <Bar> :setl noma!<CR> ] |
<S-F2> | toggle read-only | [:set ro!<CR> ] |
<C-F2> | toggle no-modify | [:setl noma!<CR> ] |
<F3> | toggle show tabs and trails | [:set list!<CR> ] |
<S-F4> | set fileformat to unix | [:set ff=unix<CR> ] |
<C-F4> | set fileformat to dos | [:set ff=dos<CR> ] |
<F5> | search for trailing spaces | [/\s\+$<CR> ] |
<S-F5> | delete trailing spaces | [:%s/\s\+$//<CR> ] |
<F6> | toggle spell checking | [:setlocal spell! spelllang=en_gb<CR> ] |
<F7> | show nonconformance to one whole sentence per line | [/^[^A-Z'"‘“(=-]\\|[.?!][^'"’”)]\\|[^.?!…'"’”)=-]$\\|^[=-]\+[^=-]\\|[^=-][=-]\+$<CR> ] |
<F11> | uuidgen | [:r !uuidgen<CR> ] |
<F12> | date-time | [:r !date.sh<CR> ] |
<S-F12> | date | [:r !dateonly.sh<CR> ] |
<C-F12> | date-time short | [:r !dateshort.sh<CR> ] |
shft-cmd-p | unmap |
! |
( |
) |
= |
ctrl-w |
g |
ctrl-c |
[ |
{ |
] |
} |
: |
" |
\ |
/ |
? |
F7 |
F8 |
F9 |
+ |
" |
| |
ctrl-q |
ctrl-t |
shft-g |
ctrl-g |
shft-b |
ctrl-b |
Fix :Exp/:Sex navigation keys – new mapping of i (cursor up) doesn't work – just move the plugin's i
key to something else:
netrw.vim
/Applications/MacVim.app/Contents/Resources/vim/runtime/autoload/
i
to b
:
- nnoremap <buffer> <silent> i :call <SID>NetrwListStyle(1)<cr>
+ nnoremap <buffer> <silent> b :call <SID>NetrwListStyle(1)<cr>
! | [leave unchanged] |
= | [leave unchanged] |
q | unmap | |
shft-q | unmap | |
ctrl-q | unmap | |
w | [inherit] switch case | [~ ] |
shft-w | unmap | |
ctrl-w | [inherit] | [leave unchanged ] |
(n)e | indent, (n) amount | [> ] |
(n)shft-e | outdent, (n) amount | [< ] |
ctrl-e | number sequence | [g<C-a> ] |
r | unmap | |
shft-r | unmap | |
ctrl-r | unmap | |
t | unmap | |
shft-t | unmap | |
ctrl-t(char) | [inherit] replace visual selection with repeated char |
a | [inherit] visual, char oriented | [v ] |
shft-a | [inherit] visual, line oriented | [shft-v ] |
ctrl-a | [inherit] visual, block oriented | [ctrl-v ] |
s(char) | unmap | |
shft-s | block insert | [I ] |
ctrl-s | block append | [A ] |
d(char) | select 'inner' text object | [i ] |
shft-d | unmap | |
ctrl-d | unmap | |
f(char) | select 'a' text object | [a ] |
shft-f | unmap | |
ctrl-f | unmap | |
g | [inherit] | [leave unchanged ] |
shft-g | unmap | |
ctrl-g | unmap |
z | unmap | |
shft-z | unmap | |
ctrl-z | unmap | |
(reg)x | [inherit] cut visual selection | [d ] |
(reg)shft-x | [inherit] cut visual selection, then insert | [c ] |
(reg)ctrl-x | [inherit] del visual selection | ["_d ] |
(reg)c | [inherit] copy visual selection | [y ] |
shft-c | [inherit] | |
ctrl-c | [inherit] | |
(n)(reg)v | paste over visual selection | [<Esc>pgv"_d ] |
(n)(reg)shft-v | paste over visual selection (and copy), (n) times | [shft-p ] |
ctrl-v | unmap |
xx | unmap |
shft-x shft-x | unmap |
ctrl-x ctrl-x | unmap |
cc | unmap |
shft-p | last char of screen line | [g$h ] |
[inherit other movement keys] |
: | [leave unchanged] | |
; | start ex command for highlighted lines | [v_: ] |
/ | search for selected text | [y/<C-R>"<CR> ] |
? | search for selected text, backwards | [y?<C-R>"<CR> ] |
" | exchange cursor position with start of visual selection | [v_o ] |
| | exchange cursor position with opposite corner of block | [v_O ] |
~ | unmap |
` | unmap |
`` | unmap |
(reg)<S-Del> | cut (same as x) | [v_<Del> ] |
gq | [leave unchanged] format lines to 'textwidth' length | |
gv | [leave unchanged] start same selection as last one | |
(n)gj | [inherit] join lines | [shft-j ] |
(n)g shft-j | [inherit] join lines (no space inserts) | [g shft-j ] |
ctrl-@ | [leave unchanged] paste previously pasted text, and exit | [ctrl-@ ] |
ctrl-q | paste previously pasted text | [ctrl-a ] |
ctrl-w | [leave unchanged] delete word backward | [ctrl-w ] |
ctrl-e | [leave unchanged] duplicate char from line below | [ctrl-e ] |
ctrl-r | duplicate char from line above | [ctrl-y ] |
ctrl-t | unmap | |
ctrl-a | trigger abbreviation | [ctrl-] ] |
ctrl-s | [leave unchanged] | |
ctrl-d | keyword completion next | [ctrl-n ] |
ctrl-f | execute command and return to insert | [ctrl-o ] |
ctrl-g | [leave unchanged] | |
ctrl-z | delete all inserted chars in current line | [ctrl-u ] |
ctrl-x | unmap | |
ctrl-c | unmap | |
ctrl-v | paste contents of default reg | [ctrl-r" ] |
ctrl-[ | [leave unchanged] exit insert mode | [<Esc> ] |
ctrl-] | abort insert mode | [ctrl-c ] |
ctrl-_ | to last position | [<Esc>ctrl-o a ] |
ctrl-y | to last position edited | [<Esc>`.a ] |
ctrl-b | start new undoable edit | [ctrl-g u ] |
ctrl-<CR> | ctrl-x sub-mode | [ctrl-x ] |
ctrl-u | unmap |
ctrl-i | [leave unchanged] fixed to <Tab> |
ctrl-o | unmap |
ctrl-p | unmap |
ctrl-h | unmap |
ctrl-n | unmap |
ctrl-m | [leave unchanged] fixed to <CR> |
ctrl-\ a-z | [leave unchanged] reserved |
ctrl-^ | [leave unchanged] toggle use of :lmap mappings |
<BS> | [leave unchanged] | |
shft-<BS> | del word backward | [ctrl-w ] |
<Del> | [leave unchanged] | |
shft-<Del> | del word foreward | [<Esc>l"_dei ] |
<Home> | home screen line | [<Esc>g^a ] |
<S-Home> | home para | [<Home> ] |
<C-Home> | start of file | [leave unchanged ] |
<End> | end screen line | [<Esc>g$i ] |
<S-End> | end para | [<End> ] |
<C-End> | end of file | [leave unchanged ] |
<PageUp> | [leave unchanged] | |
<S-PageUp> | screen top | [<Esc><S-h>a ] |
<C-PageUp> | prev tab | [leave unchanged ] |
<PageDown> | [leave unchanged] | |
<S-PageDown> | screen bottom | [<Esc><S-l>a ] |
<C-PageDown> | next tab | [leave unchanged ] |
<Up> | up screen line | [<Esc>gka ] |
<S-Up> | up para | [<Up> ] |
<C-Up> | scroll line up | [<Esc>ctrl-ya ] |
<Down> | down screen line | [<Esc>gja ] |
<S-Down> | down para | [<Down> ] |
<C-Down> | scroll line down | [<Esc>ctrl-ea ] |
<Left> | [leave unchanged] | |
<S-Left> | word left start | [leave unchanged ] |
<C-Left> | word left start, ignore punctuation | [<Esc>shft-bi ] |
<Right> | [leave unchanged] | |
<S-Right> | word right start | [leave unchanged ] |
<C-Right> | word right start, ignore punctuation | [<Esc>shft-wa ] |
£ | # |
§ | ` |
± | ~ |
tab | complete pattern / next match | [leave unchanged ] |
shft-tab | complete pattern / previous match | [leave unchanged ] |
ctrl-q | complete pattern, with longest match | [ctrl-l ] |
ctrl-w | complete pattern, with all matches | [ctrl-a ] |
ctrl-e | go to next wildcard match | [ctrl-n ] |
ctrl-r | go to previous wildcard match | [ctrl-p ] |
ctrl-r ctrl-r | unmap | |
ctrl-t | list completions matching pattern | [ctrl-d ] |
ctrl-o | insert number as byte | [ctrl-v ] |
ctrl-a | trigger abbreviation | [ctrl-] ] |
ctrl-v | paste register or object as typed | [ctrl-r+ ] |
ctrl-h | open command-line window | [ctrl-f ] |
shft-<BS> | del word backward | [ctrl-w ] |
(other special keys, leave unchanged) |
£ | # (to match insert mode) | |
:Tabv[iew] | open new tab and view file | [(using :tabe and :view) ] |
All the Vim code.
" === ErgoVim key mappings ===
" Version 1.1
"
" http://www.hxa.name/articles/content/ergovim-key-mappings_hxa7241_2010.html
" --- normal mode ---
" leave unchanged: ! and !!
" --- tab and pane ---
noremap @ :Mr<CR>
noremap # :tabedit
noremap £ :tabedit
noremap $ :tabfind
noremap % <C-w>s
noremap ^ <C-w>o
noremap & <C-w><S-w>
noremap * <C-w><C-w>
" leave unchanged: (
" leave unchanged: )
noremap 0 :up<CR>
noremap - <C-o>
noremap _ <C-i>
" leave unchanged: =
noremap + <Nop>
" --- edit ---
noremap q .
noremap <S-q> @:
noremap <C-q> <Nop>
noremap w ~
noremap <S-w> g~
" leave unchanged: <C-w>
noremap e >>
noremap <S-e> <<
noremap <C-e> <C-a>
noremap r daw
noremap <S-r> ciw
noremap <C-r> "_daw
noremap t x
noremap <S-t> r
noremap <C-t> <Nop>
noremap a v
noremap <S-a> <S-v>
noremap <C-a> <C-v>
noremap s g^i
noremap <S-s> <S-o>
noremap <C-s> <S-o><Esc>
noremap d g$a
noremap <S-d> o
noremap <C-d> o<Esc>
noremap f i
noremap <S-f> a
noremap <C-f> <S-r>
" leave unchanged: g
noremap <S-g> <Nop>
noremap <C-g> <Nop>
noremap z u
noremap <S-z> <C-r>
noremap <C-z> :undolist<CR>
noremap x d
noremap <S-x> c
noremap <C-x> "+d
noremap c y
noremap <S-c> "Ay
noremap <S-c><S-c> "Ayy
" leave unchanged: <C-c>
noremap v <S-p>
noremap <S-v> p
" for mac: noremap <C-v> <Nop>
" for linux:
noremap <C-v> "+p
noremap xx dd
noremap <S-x><S-x> cc
noremap <C-x><C-x> "_dd
noremap cc yy
onoremap d i
onoremap f a
" --- move ---
noremap y %
noremap <S-y> g;
noremap <C-y> g,
noremap u <S-b>
noremap <S-u> b
noremap <C-u> gE
noremap i gk
noremap <S-i> <C-b>
noremap <C-i> <C-y>
noremap o <S-w>
noremap <S-o> w
noremap <C-o> <S-e>
noremap p g$
noremap <S-p> g$
noremap <C-p> $
" leave unchanged: [
" leave unchanged: {
" leave unchanged: ]
" leave unchanged: }
noremap h g^
noremap <S-h> g0
noremap <C-h> ^
noremap j h
noremap <S-j> <S-h>
noremap <C-j> gg
noremap k gj
noremap <S-k> <C-f>
noremap <C-k> <C-e>
" leave unchanged: l
" leave unchanged: <S-l>
noremap <C-l> <S-g>
noremap : q:
noremap :: q/
noremap ; :
noremap ' "
" leave unchanged: "
" leave unchanged: \
noremap <Bar> <Nop>
" --- search ---
" leave unchanged: n
" leave unchanged: <S-n>
noremap <C-n> :nohlsearch<CR>
noremap m f
noremap <S-m> <S-f>
noremap <C-m> ;
noremap , g*
noremap < g#
noremap << <Nop>
noremap . *
noremap > #
noremap >> <Nop>
" leave unchanged: /
" leave unchanged: ?
" --- record ---
noremap ~ q
noremap ` @
noremap `` @@
" --- mark ---
noremap <S-Space> m
noremap <C-Space> m`
noremap <Space> `
noremap <Space><Space> ``
" --- special keys ---
noremap <BS> "_<S-x>
noremap <S-BS> "_db
noremap <Del> "_x
noremap <S-Del> "_de
noremap <Home> g0
noremap <S-Home> <Home>
" leave unchanged: <C-Home>
noremap <End> g$
noremap <S-End> <End>
" leave unchanged: <C-End>
" leave unchanged: <PageUp>
noremap <S-PageUp> <S-h>
" leave unchanged: <C-PageUp>
" leave unchanged: <PageDown>
noremap <S-PageDown> <S-l>
" leave unchanged: <C-PageDown>
noremap <C-S-PageUp> :tabm-1<CR>
noremap <C-S-PageDown> :tabm+1<CR>
noremap <Up> gk
noremap <S-Up> <Up>
noremap <C-Up> <C-y>
noremap <Down> gj
noremap <S-Down> <Down>
noremap <C-Down> <C-e>
" leave unchanged: <Left>
" leave unchanged: <S-Left>
noremap <C-Left> <S-b>
" leave unchanged: <Right>
" leave unchanged: <S-Right>
noremap <C-Right> <S-w>
" --- g prefixeds ---
noremap gm gd
noremap g<S-m> gD
noremap gj <S-j>
" leave unchanged: g<S-j>
noremap g: q:
noremap g/ q/
" --- other ---
noremap b z
noremap <S-b> <Nop>
noremap <C-b> <Nop>
noremap <D-P> <Nop>
noremap <F2> :set ro! <Bar> :setl noma!<CR>
noremap <S-F2> :set ro!CR>
noremap <C-F2> :setl noma!<CR>
noremap <F3> :set list!<CR>
noremap <S-F4> :set ff=unix<CR>
noremap <C-F4> :set ff=dos<CR>
noremap <F5> /\s\+$<CR>
noremap <S-F5> :%s/\s\+$//<CR>
noremap <F6> :setlocal spell! spelllang=en_gb<CR>
noremap <F7> /^[^A-Z'"‘“(=-]\\|[.?!][^'"’”)]\\|[^.?!…'"’”)=-]$\\|^[=-]\+[^=-]\\|[^=-][=-]\+$<CR>
noremap <F11> :r !uuidgen<CR>
noremap <F12> :r !date.sh<CR>
noremap <S-F12> :r !dateonly.sh<CR>
noremap <C-F12> :r !dateshort.sh<CR>
" --- visual mode ---
" leave unchanged: !
" leave unchanged: =
vnoremap q <Nop>
vnoremap <S-q> <Nop>
vnoremap <C-q> <Nop>
" inherit: w
vnoremap <S-w> <Nop>
" inherit: <C-w>
vnoremap e >
vnoremap <S-e> <
vnoremap <C-e> g<C-a>
vnoremap r <Nop>
vnoremap <S-r> <Nop>
vnoremap <C-r> <Nop>
vnoremap t <Nop>
vnoremap <S-t> <Nop>
" inherit: <C-t>
" leave unchanged: a
" leave unchanged: <S-a>
" leave unchanged: <C-a>
vnoremap s <Nop>
vnoremap <S-s> I
vnoremap <C-s> A
vnoremap d i
vnoremap <S-d> <Nop>
vnoremap <C-d> <Nop>
vnoremap f a
vnoremap <S-f> <Nop>
vnoremap <C-f> <Nop>
" inherit: g
vnoremap <S-g> <Nop>
vnoremap <C-g> <Nop>
vnoremap z <Nop>
vnoremap <S-z> <Nop>
vnoremap <C-z> <Nop>
" inherit: x
" inherit: <S-x>
" inherit: <C-x>
" inherit: c
" inherit: S-c
" for mac: " inherit: <C-c>
" for linux:
vnoremap <C-c> "+y
vnoremap v <Esc>pgv"_d
vnoremap <S-v> <S-p>
" for mac: vnoremap <C-v> <Nop>
" for linux:
vnoremap <C-v> c<ESC>"+p
vnoremap <S-p> g$h
vunmap xx
vunmap <S-x><S-x>
vunmap <C-x><C-x>
vunmap cc
" leave unchanged: :
vnoremap ; v_:
" http://vim.wikia.com/wiki/Search_for_visually_selected_text
vnoremap <silent> / :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> ? :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
" vnoremap / y/\V<C-R>"<CR>
" vnoremap ? y?\V<C-R>"<CR>
vnoremap " o
vnoremap <Bar> <S-o>
vnoremap ~ <Nop>
vnoremap ` <Nop>
vunmap ``
vnoremap <S-Del> v_<Del>
" leave unchanged: gq
" leave unchanged: gv
" inherit: gj
" inherit: g shft-j
" --- insert mode ---
" --- edit
" leave unchanged: <C-@>
inoremap <C-q> <C-a>
" leave unchanged: <C-w>
" leave unchanged: <C-e>
inoremap <C-r> <C-y>
inoremap <C-t> <Nop>
inoremap <C-a> <C-]>
" leave unchanged: <C-s>
inoremap <C-d> <C-n>
inoremap <C-f> <C-o>
" leave unchanged: <C-g>
inoremap <C-z> <C-u>
inoremap <C-x> <Nop>
inoremap <C-c> <Nop>
" for mac: inoremap <C-v> <C-r>
" for linux:
inoremap <C-v> <ESC>"+pa
" leave unchanged: <C-[>
inoremap <C-]> <C-c>
" --- move, etc.
inoremap <C-_> <Esc><C-o>a
inoremap <C-y> <Esc>`.a
inoremap <C-b> <C-g>u
inoremap <C-CR> <C-x>
" --- other
inoremap <C-u> <Nop>
" leave unchanged: <C-i> -- fixed to <Tab>
inoremap <C-o> <Nop>
inoremap <C-p> <Nop>
inoremap <C-h> <Nop>
inoremap <C-n> <Nop>
" leave unchanged: <C-m> -- fixed to <CR>
" leave unchanged: <C-\>
" leave unchanged: <C-^>
" --- special keys
" leave unchanged <BS>
inoremap <S-BS> <C-w>
" leave unchanged <Del>
inoremap <S-Del> <Esc>l"_dei
inoremap <Home> <Esc>g^a
inoremap <S-Home> <Home>
" leave unchanged <C-Home>
inoremap <End> <Esc>g$i
inoremap <S-End> <End>
" leave unchanged <C-End>
" leave unchanged <PageUp>
inoremap <S-PageUp> <Esc><S-h>a
" leave unchanged <C-PageUp>
" leave unchanged <PageDown>
inoremap <S-PageDown> <Esc><S-l>a
" leave unchanged <C-PageDown>
inoremap <Up> <Esc>gka
inoremap <S-Up> <Up>
inoremap <C-Up> <Esc><C-y>a
inoremap <Down> <Esc>gja
inoremap <S-Down> <Down>
inoremap <C-Down> <Esc><C-e>a
" leave unchanged <Left>
" leave unchanged <S-Left>
inoremap <C-Left> <Esc><S-b>i
" leave unchanged <Right>
" leave unchanged <S-Right>
inoremap <C-Right> <Esc><S-w>a
" --- make UK keyboard more USA
"inoremap £ #
inoremap § `
inoremap ± ~
" --- command-line mode ---
" --- pattern complete
cnoremap <C-q> <C-l>
cnoremap <C-w> <C-a>
cnoremap <C-e> <C-n>
cnoremap <C-r> <C-p>
"cunmap <C-r><C-r>
cnoremap <C-t> <C-d>
" --- other
cnoremap <C-o> <C-v>
cnoremap <C-a> <C-]>
cnoremap <C-v> <C-r>+
cnoremap <C-h> <C-f>
cnoremap <S-BS> <C-w>
"cnoremap £ #
command -nargs=+ -bang -bar -complete=file Tabview tabe | view <args> | setl noma
command Tabrecent tabe | browse oldfiles
let maplocalleader = "\\"