1 " Redesigned mapping for the Colemak layout for Vim 7.0
2 " 2008-04-21 Shai Coleman, http://colemak.com/ . Public domain.
4 " * Use ":source colemak.vim" (without quotes) to load this file. Adjust path to colemak.vim if needed.
5 " * Add the line: "source colemak.vim" (without quotes) in your .vimrc file to automatically load this file.
6 " It is recommended to load colemak.vim after all other Vim scripts.
8 " recommended commands for running under Linux console
9 " $ export TERM=xterm # make Backspace and Ctrl-H work correctly
10 " $ stty -ixon -ixoff # make Ctrl+S and Ctrl+Q work correctly
13 " Colemak layout: | QWERTY layout:
14 " `12345 67890-= Move Around: | (instead of) `12345 67890-=
15 " qwfpg jlUy;[]\ u | k qwert yuiop[]\
16 " arstd hNEIo' n i | h l asdfg HJKL;'
17 " zxcvb km,./ e | j zxcvb nm,./
19 " (nv ) n =Left , i =Right , u =Up , e =Down
20 " (nv ) N =Left*5 , I =Right*5 , U =Up*5 , E =Down*5
21 " ( ic) <M-n>=Left , <M-i>=Right , <M-u>=Up , <M-e>=Down
22 " ( ic) <M-N>=Left*5 , <M-I>=Right*5 , <M-U>=Up*5 , <M-E>=Down*5
23 " (nv ) l =Left 1 word , y =Right 1 word
24 " (nv ) <C-l>=Left 1 WORD , <C-y>=Right 1 WORD
25 " (nv ) L =Home , Y =End
26 " (nv ) j =PageUp , h =PageDown
27 " (nv ) <C-j>=File start , <C-h>=File end
28 " (nv ) - =First line , _ =Last line, <count>-=Goto line #
29 " (nvi ) <Tab>=Escape (also stops search highlight in normal mode)
32 " (nvic) <Space>=Space
33 " ( v ) <S-Space>=Undo space
36 " (c - command line, i - insert mode, n - normal mode, v - visual+select mode)
38 if v:version < 700 | echohl WarningMsg | echo "colemak.vim: You need Vim version 7.0 or later" | echohl None | finish | endif
40 " incompatible scripts: matchit.vim (fix available)
42 " recommended settings, enabled by default
43 set nocompatible " make Vim behave in a more useful way
44 set nostartofline " keep cursor in the same column if possible
45 set whichwrap=b,s,[,],<,>,h,l " allow cursor to wrap between lines
46 set virtualedit=block " allow virtual editing in Visual block mode
47 set lazyredraw " don't redraw screen while executing macros/mappings
48 set scrolloff=1 " minimal number of screen lines to keep above and below the cursor
49 set incsearch " enable incremental search
50 set backspace=indent,eol,start " allow backspacing over everything in insert mode
51 set winaltkeys=no " allow mapping of alt (meta) key shortcuts
52 set ruler " show the cursor position all the time
53 set showcmd " display incomplete commands
54 syntax on " enable syntax highlighting
56 " recommended settings, but not enabled by default
57 "if has("gui_running") | source $VIMRUNTIME/mswin.vim | endif
59 " other optional settings
60 "set hlsearch " highlight search patterns
61 "set ignorecase " ignore case
62 "set smartcase " ignore case when the pattern contains lowercase letters only
63 "set showtabline=2 " always show tab page labels
64 "set number " display line numbers
66 " Make Alt pop up the menu for all keys, mappings in use will be overridden subsequentially
67 noremap <silent> <M-a> :simalt a<CR>|noremap <silent> <M-b> :simalt b<CR>|noremap <silent> <M-c> :simalt c<CR>|
68 noremap <silent> <M-d> :simalt d<CR>|noremap <silent> <M-e> :simalt e<CR>|noremap <silent> <M-f> :simalt f<CR>|
69 noremap <silent> <M-g> :simalt g<CR>|noremap <silent> <M-h> :simalt h<CR>|noremap <silent> <M-i> :simalt i<CR>|
70 noremap <silent> <M-j> :simalt j<CR>|noremap <silent> <M-k> :simalt k<CR>|noremap <silent> <M-l> :simalt l<CR>|
71 noremap <silent> <M-m> :simalt m<CR>|noremap <silent> <M-n> :simalt n<CR>|noremap <silent> <M-o> :simalt o<CR>|
72 noremap <silent> <M-p> :simalt p<CR>|noremap <silent> <M-q> :simalt q<CR>|noremap <silent> <M-r> :simalt r<CR>|
73 noremap <silent> <M-s> :simalt s<CR>|noremap <silent> <M-t> :simalt t<CR>|noremap <silent> <M-u> :simalt u<CR>|
74 noremap <silent> <M-v> :simalt v<CR>|noremap <silent> <M-w> :simalt w<CR>|noremap <silent> <M-x> :simalt x<CR>|
75 noremap <silent> <M-y> :simalt y<CR>|noremap <silent> <M-z> :simalt z<CR>|
77 " Turbo navigation mode
78 " Modified to work with counts, see :help complex-repeat
79 nnoremap <silent> N @='5n'<CR>|xnoremap <silent> N @='5n'<CR>|onoremap N 5h|
80 nnoremap <silent> U @='5u'<CR>|xnoremap <silent> U @='5u'<CR>|onoremap U 5k|
81 nnoremap <silent> E @='5e'<CR>|xnoremap <silent> E @='5e'<CR>|onoremap E 5j|
82 nnoremap <silent> I @='5i'<CR>|xnoremap <silent> I @='5i'<CR>|onoremap I 5l|
83 inoremap <M-N> <C-o>5h|cnoremap <M-N> <Left><Left><Left><Left><Left>|
84 inoremap <M-U> <C-o>5k|cnoremap <M-U> <Up><Up><Up><Up><Up>|
85 inoremap <M-E> <C-o>5j|cnoremap <M-E> <Down><Down><Down><Down><Down>|
86 inoremap <M-I> <C-o>5l|cnoremap <M-I> <Right><Right><Right><Right><Right>|
89 nnoremap n h|xnoremap n h|onoremap n h|
90 nnoremap u k|xnoremap u k|onoremap u k|
91 nnoremap e j|xnoremap e j|onoremap e j|
92 nnoremap i l|xnoremap i l|onoremap i l|
93 inoremap <M-n> <Left>|cnoremap <M-n> <Left>|
94 inoremap <M-u> <Up>|cnoremap <M-u> <Up>|
95 inoremap <M-e> <Down>|cnoremap <M-e> <Down>|
96 inoremap <M-i> <Right>|cnoremap <M-i> <Right>|
100 nnoremap L ^|xnoremap L ^|onoremap L ^|
101 nnoremap Y $|xnoremap Y $|onoremap Y $|
102 inoremap <M-L> <Home>|cnoremap <M-L> <Home>|
103 inoremap <M-Y> <End>|cnoremap <M-Y> <End>|
106 nnoremap <silent> <expr> j (winheight(0)-1) . "\<C-u>"
107 nnoremap <silent> <expr> h (winheight(0)-1) . "\<C-d>"
108 xnoremap <silent> <expr> j (winheight(0)-1) . "\<C-u>"
109 xnoremap <silent> <expr> h (winheight(0)-1) . "\<C-d>"
110 inoremap <silent> <expr> <M-j> "\<C-o>" . (winheight(0)-1) . "\<C-u>"
111 inoremap <silent> <expr> <M-h> "\<C-o>" . (winheight(0)-1) . "\<C-d>"
112 nnoremap <silent> <expr> <PageUp> (winheight(0)-1) . "\<C-u>"
113 nnoremap <silent> <expr> <PageDown> (winheight(0)-1) . "\<C-d>"
114 vnoremap <silent> <expr> <PageUp> (winheight(0)-1) . "\<C-u>"
115 vnoremap <silent> <expr> <PageDown> (winheight(0)-1) . "\<C-d>"
116 vnoremap <silent> <expr> <S-PageUp> (winheight(0)-1) . "\<C-u>"
117 vnoremap <silent> <expr> <S-PageDown> (winheight(0)-1) . "\<C-d>"
118 cnoremap <M-j> <PageUp>|
119 cnoremap <M-h> <PageDown>|
122 nnoremap <silent> <expr> <C-u> (winheight(0)/2) . "\<C-u>"
123 nnoremap <silent> <expr> <C-e> (winheight(0)/2) . "\<C-d>"
124 vnoremap <silent> <expr> <C-u> (winheight(0)/2) . "\<C-u>"
125 vnoremap <silent> <expr> <C-e> (winheight(0)/2) . "\<C-d>"
128 nnoremap - gg|xnoremap - gg|onoremap - gg|
129 nnoremap _ G|xnoremap _ G|onoremap _ G|
131 " Words forwards/backwards
132 nnoremap l b|xnoremap l b|onoremap l b|
133 nnoremap y w|xnoremap y w|onoremap y w|
134 inoremap <M-l> <C-Left>|cnoremap <M-l> <C-Left>|
135 inoremap <M-y> <C-Right>|cnoremap <M-y> <C-Right>|
137 nnoremap <C-l> B|vnoremap <C-l> B|onoremap <C-l> B|
138 nnoremap <C-y> W|vnoremap <C-y> W|onoremap <C-y> W|
141 " e.g. dip (delete inner paragraph) is now drp
144 " End of word forwards/backwards
145 "nnoremap ; e|xnoremap ; e|onoremap ; e|
146 "nnoremap g; ge|xnoremap g; ge|onoremap g; ge|
148 "nnoremap ; z|xnoremap ; z|
151 nnoremap ; :|xnoremap ; :|
153 " for virtualedit=onemore
154 "set virtualedit=block,onemore
155 "nnoremap <End> <End><Right>|
156 "snoremap <End> <End><Right>|
157 "xnoremap <End> <End><Right>|
160 nnoremap x x|xnoremap x d|
161 nnoremap c y|xnoremap c y|
162 nnoremap v gP|xnoremap v gP|
163 nnoremap X dd|xnoremap X d|
164 nnoremap C yy|xnoremap C y|
165 nnoremap V p|xnoremap V p|
166 nnoremap <C-c> "+Y| " <C-c> with no selection copies current line to clipboard
167 nnoremap <C-x> "+dd| " <C-x> with no selection cuts current line to clipboard
168 " (GUI) Make <C-c>/<C-v> work also in command mode, but must be selected using the mouse
169 cnoremap <C-c> <C-y>|
170 cnoremap <C-Insert> <C-y>|
171 cnoremap <C-v> <C-r>+|
172 cnoremap <S-Insert> <C-r>+|
175 nnoremap z u|xnoremap z :<C-u>undo<CR>|
176 nnoremap gz U|xnoremap gz U<C-u>undo<CR>|
177 nnoremap Z <C-r>|xnoremap Z :<C-u>redo<CR>|
178 inoremap <CR> <C-g>u<CR>| " Break undo chain (Tip #1054)
180 " Cursor position jumplist
185 " Use < and > to navigate in the help file instead
186 au FileType help nnoremap <buffer> < <C-t>|
187 au FileType help nnoremap <buffer> > <C-]>|
188 au FileType help nnoremap <buffer> <CR> <C-]>|
189 au FileType help nnoremap <buffer> <Backspace> <C-t>|
190 au FileType help nnoremap <buffer> <silent> <expr> <Space> (winheight(0)-1) . "\<C-d>0"|
191 au FileType help nnoremap <buffer> <silent> <expr> <S-Space> (winheight(0)-1) . "\<C-u>0"|
192 nnoremap <silent> <F1> :tab help<CR>
193 " opens commands in a new tab
194 cnoreabbr <expr> h (getcmdtype() . getcmdline() != ':h' ? 'h' : 'tab help')
195 cnoreabbr <expr> he (getcmdtype() . getcmdline() != ':he' ? 'he' : 'tab help')
196 cnoreabbr <expr> hel (getcmdtype() . getcmdline() != ':hel' ? 'hel' : 'tab help')
197 cnoreabbr <expr> help (getcmdtype() . getcmdline() != ':help' ? 'help' : 'tab help')
198 cnoreabbr <expr> e (getcmdtype() . getcmdline() != ':e' ? 'e' : 'tabedit' )
199 cnoreabbr <expr> ed (getcmdtype() . getcmdline() != ':ed' ? 'ed' : 'tabedit' )
200 cnoreabbr <expr> edi (getcmdtype() . getcmdline() != ':edi' ? 'edi' : 'tabedit' )
201 cnoreabbr <expr> edit (getcmdtype() . getcmdline() != ':edit' ? 'edit' : 'tabedit' )
203 " (GUI) Start/end of document
204 nnoremap <C-S-Home> <S-Home>gg|vnoremap <C-S-Home> <S-Home>gg|inoremap <C-S-Home> <S-Home>gg|
205 nnoremap <C-Home> gg0|xnoremap <C-Home> gg0|snoremap <C-Home> <C-Home><Home>|inoremap <C-Home> <C-o>gg<C-o>0|
206 nnoremap <C-j> gg0|xnoremap <C-j> gg0|snoremap <C-j> <C-Home><Home>|
207 nnoremap <C-End> G$|xnoremap <C-End> G$|snoremap <C-End> <C-End><End>|inoremap <C-End> <C-o>G<C-o>$|
208 nnoremap <C-h> G$|xnoremap <C-h> G$|snoremap <C-h> <C-End><End>|
210 " (GUI) Move cursor to top/bottom of screen
211 nnoremap <C-PageUp> H|vnoremap <C-PageUp> H|inoremap <C-PageUp> <C-o>H|
212 nnoremap <C-PageDown> L|vnoremap <C-PageDown> L|inoremap <C-PageDown> <C-o>L|
214 " (GUI) Scroll in place
215 nnoremap <C-Up> <C-y>|inoremap <C-Up> <C-o><C-y>|
216 nnoremap <C-Down> <C-e>|inoremap <C-Down> <C-o><C-e>|
218 " (GUI) Live line reordering (very useful)
219 nnoremap <silent> <C-S-Up> :move .-2<CR>|
220 nnoremap <silent> <C-S-Down> :move .+1<CR>|
221 vnoremap <silent> <C-S-Up> :move '<-2<CR>gv|
222 vnoremap <silent> <C-S-Down> :move '>+1<CR>gv|
223 inoremap <silent> <C-S-Up> <C-o>:move .-2<CR>|
224 inoremap <silent> <C-S-Down> <C-o>:move .+1<CR>|
226 " inSert/Replace/append (T)
232 " Make insert/add work also in visual line mode like in visual block mode
233 xnoremap <silent> <expr> s (mode() =~# "[V]" ? "\<C-v>0o$I" : "I")
234 xnoremap <silent> <expr> S (mode() =~# "[V]" ? "\<C-v>0o$I" : "I")
235 xnoremap <silent> <expr> t (mode() =~# "[V]" ? "\<C-v>0o$A" : "A")
236 xnoremap <silent> <expr> T (mode() =~# "[V]" ? "\<C-v>0o$A" : "A")
239 nnoremap w c|xnoremap w c|
240 nnoremap W C|xnoremap W C|
244 nnoremap a v|xnoremap a v|
245 nnoremap A V|xnoremap A V|
246 nnoremap <C-a> <Esc>ggVG$|xnoremap <C-a> <Esc>ggVG$|vnoremap <C-a> <Esc>ggVG$|
247 nnoremap <C-b> <C-v>|
248 " Allow switching from visual line to visual block mode
249 vnoremap <silent> <expr> <C-b> (mode() =~# "[vV]" ? "\<C-v>0o$" : "")
251 " (GUI) Visual mode with mouse
252 noremap <C-LeftMouse> <LeftMouse><Esc><C-v>|
253 noremap <S-LeftMouse> <LeftMouse><Esc>V|
254 noremap <C-LeftDrag> <LeftDrag>|
256 inoremap <C-b> <C-v>|cnoremap <C-b> <C-v>|
261 nnoremap p t|xnoremap p t|onoremap p t|
262 nnoremap P T|xnoremap P T|onoremap P T|
263 nnoremap b ;|xnoremap b ;|onoremap b ;|
264 nnoremap B ,|xnoremap B ,|onoremap B ,|
265 nnoremap k n|xnoremap k n|onoremap k n|
266 nnoremap K N|xnoremap K N|onoremap K N|
269 nnoremap <C-f> :<C-u>promptrepl<CR>|vnoremap <C-f> :<C-u>promptrepl<CR>|inoremap <C-f> <C-o>:<C-u>promptrepl<CR>
270 nnoremap <F3> n|vnoremap <F3> n|inoremap <F3> <C-o>n|
271 nnoremap <S-F3> N|vnoremap <S-F3> N|inoremap <S-F3> <C-o>N|
272 nnoremap <C-F3> *|vnoremap <C-F3> *|inoremap <C-F3> <C-o>*|
273 nnoremap <C-S-F3> #|vnoremap <C-S-F3> #|inoremap <C-S-F3> <C-o>#|
274 "http://xona.com/2005/08/02.html
277 "nnoremap <C-r> <C-l>|vnoremap <C-r> <C-l>|
280 noremap <silent> <C-w> :<C-u>call CloseWindow()<CR>|inoremap <silent> <C-w> <C-o>:<C-u>call CloseWindow()<CR>|cnoremap <silent> <C-w> <C-c>:<C-u>call CloseWindow()<CR>|
281 noremap <silent> <C-t> :<C-u>tabnew<CR>|
282 "noremap <silent> <C-n> :<C-u>tabnew<CR>|
283 function! CloseWindow()
284 if winheight(2) < 0 | confirm quit | else | confirm close | endif
286 "nnoremap <silent> <C-s> :<C-u>update<CR>|inoremap <C-s> <C-o>:<C-u>update<CR>|
289 nnoremap <C-o> :<C-u>browse tabnew<CR>|vnoremap <C-o> :<C-u>browse tabnew<CR>|
292 noremap <silent> <C-S-Tab> :<C-u>tabprev<CR>|
293 noremap <silent> <C-Tab> :<C-u>tabnext<CR>|
296 " Free mappings: ,/+/H/~
298 " Macros (replay the macro recorded by qq)
302 "nnoremap Q :copy .+0<CR>|
307 " , is reserved for your custom remapping
310 " Misc overridden keys must be prefixed with g
311 nnoremap gs s|xnoremap gs s|
312 nnoremap gX X|xnoremap gX X|
313 nnoremap gU U|xnoremap gU U|
314 nnoremap gQ Q|xnoremap gQ Q|
315 nnoremap gK K|xnoremap gK K|
317 nnoremap gh K|xnoremap gh K|
319 " Window handling: <C-w> is now <C-r>
320 nnoremap <C-r> <C-w>|xnoremap <C-r> <C-w>|
321 " <C-r><C-r> opens a new window
322 nnoremap <C-r><C-r> <C-w>n|xnoremap <C-r><C-r> <C-w>n|
323 nnoremap <C-r>n <C-w>h|xnoremap <C-r>n <C-w>h|
324 nnoremap <C-r>u <C-w>k|xnoremap <C-r>u <C-w>k|
325 nnoremap <C-r>e <C-w>j|xnoremap <C-r>e <C-w>j|
326 nnoremap <C-r>i <C-w>l|xnoremap <C-r>i <C-w>l|
328 nnoremap <Space> i<Space><Esc><Right>|
329 xnoremap <silent> <Space> :<C-u>let b:tmp_var=&sw\|set sw=1\|normal! gv><CR>:<C-u>let &sw=b:tmp_var\|normal! gv<CR>
330 xnoremap <silent> <S-Space> :<C-u>let b:tmp_var=&sw\|set sw=1\|normal! gv<<CR>:<C-u>let &sw=b:tmp_var\|normal! gv<CR>
332 " The Tab key is mapped to Escape. Press Shift-Tab to insert a Tab.
333 " To minimize Tab use, you can use '<', '>' and ':set autoindent'
334 nnoremap <silent> <Tab> <Esc>:nohlsearch<bar>pclose<CR>|
335 vnoremap <Tab> <Esc><Nul>| " <Nul> added to fix select mode problem
336 inoremap <Tab> <Esc>|
337 nnoremap <S-Tab> i<Tab><Esc><Right>
338 vnoremap <S-Tab> >gv|
339 inoremap <S-Tab> <Tab>|
342 nnoremap <CR> i<CR><Esc>|
343 inoremap <S-CR> <CR>|
344 nnoremap <S-CR> O<Esc>|
345 nnoremap <C-CR> o<Esc>|inoremap <C-CR> <C-o>o|
348 nnoremap <C-d> "_dw|vnoremap <C-d> "_d|inoremap <C-d> <Delete>|cnoremap <C-d> <Delete>|
349 nnoremap <Delete> "_x|vnoremap <Delete> "_d|
350 nnoremap <Backspace> a<Left><Backspace><Right><Esc>|vnoremap <Backspace> "_d|
351 nnoremap <C-Backspace> a<Left><C-W><Right><Esc>|inoremap <C-Backspace> <C-w>|cnoremap <C-Backspace> <C-w>|
352 nnoremap <C-Delete> "_dw|inoremap <C-Delete> <C-o>"_dw|cnoremap <C-Delete> <Delete>|
353 nnoremap <S-Backspace> "_d^|inoremap <S-Backspace> <Backspace>|cnoremap <S-Backspace> <Backspace>|
354 nnoremap <S-Delete> "_d$|inoremap <S-Delete> <Delete>|cnoremap <S-Delete> <Delete>|
357 inoremap <M-?> <C-p>|
358 inoremap <M-/> <C-n>|
361 inoremap <C-S-Space> <C-p>|
362 inoremap <expr> <C-Space> (&omnifunc == '' <bar><bar> pumvisible() ? "\<C-n>" : "\<C-x>\<C-o>")
363 inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
365 "Tip #1386, Make Vim completion popup menu work just like in an IDE
366 "set completeopt=longest,menuone
367 "inoremap <expr> <C-n> pumvisible() ? "\<lt>C-n>" : "\<lt>C-n>\<lt>C-r>=pumvisible() ? \"\\<lt>Down>\" : \"\"\<lt>CR>"
368 "inoremap <expr> <M-;> pumvisible() ? "\<lt>C-n>" : "\<lt>C-x>\<lt>C-o>\<lt>C-n>\<lt>C-p>\<lt>C-r>=pumvisible() ? \"\\<lt>Down>\" : \"\"\<lt>CR>"