From 245ca3a2b49c1a37a731172c6cbda46b6db603c2 Mon Sep 17 00:00:00 2001 From: Alex Frost Date: Wed, 16 Jul 2014 23:51:45 +0100 Subject: [PATCH] separate mac and linux vim keymaping --- vim/settings.vim | 13 ++++- vim/settings/yadr-keymap-linux.vim | 81 ++++++++++++++++++++++++++++++ vim/settings/yadr-keymap-mac.vim | 81 ++++++++++++++++++++++++++++++ vim/settings/yadr-keymap.vim | 72 -------------------------- 4 files changed, 174 insertions(+), 73 deletions(-) create mode 100644 vim/settings/yadr-keymap-linux.vim create mode 100644 vim/settings/yadr-keymap-mac.vim diff --git a/vim/settings.vim b/vim/settings.vim index e2538db..81c3141 100644 --- a/vim/settings.vim +++ b/vim/settings.vim @@ -1,4 +1,15 @@ +let vimsettings = '~/.vim/settings' +let uname = system("uname -s") + +for fpath in split(globpath(vimsettings, '*.vim'), '\n') + + if (fpath == expand(vimsettings) . "/yadr-keymap-mac.vim") && uname[:4] ==? "linux" + continue " skip mac mappings for linux + endif + + if (fpath == expand(vimsettings) . "/yadr-keymap-linux.vim") && uname[:4] !=? "linux" + continue " skip linux mappings for mac + endif -for fpath in split(globpath('~/.vim/settings', '*.vim'), '\n') exe 'source' fpath endfor diff --git a/vim/settings/yadr-keymap-linux.vim b/vim/settings/yadr-keymap-linux.vim new file mode 100644 index 0000000..fdc6008 --- /dev/null +++ b/vim/settings/yadr-keymap-linux.vim @@ -0,0 +1,81 @@ +" ======================================== +" Linux specific General vim sanity improvements +" ======================================== +" +" ======================================== +" RSI Prevention - keyboard remaps +" ======================================== +" Certain things we do every day as programmers stress +" out our hands. For example, typing underscores and +" dashes are very common, and in position that require +" a lot of hand movement. Vim to the rescue +" +" Now using the middle finger of either hand you can type +" underscores with Ctrl-k or Ctrl-d, and add Shift +" to type dashes +imap _ +imap _ +imap - +imap - + +" Change inside various enclosures with Ctrl-" and Ctrl-' +" The f makes it find the enclosure so you don't have +" to be standing inside it +nnoremap f'ci' +nnoremap f"ci" +nnoremap f(ci( +nnoremap f)ci) +nnoremap f[ci[ +nnoremap f]ci] + +" ==== NERD tree +" Ctrl-Shift-N for nerd tree +nmap :NERDTreeToggle + +" move up/down quickly by using Ctrl-j, Ctrl-k +" which will move us around by functions +nnoremap } +nnoremap { +autocmd FileType ruby map ]m +autocmd FileType ruby map [m +autocmd FileType rspec map } +autocmd FileType rspec map { +autocmd FileType javascript map } +autocmd FileType javascript map { + +" Command-/ to toggle comments +map :TComment +imap :TCommenti + +" Use Alt- numbers to pick the tab you want +map :tabn 1 +map :tabn 2 +map :tabn 3 +map :tabn 4 +map :tabn 5 +map :tabn 6 +map :tabn 7 +map :tabn 8 +map :tabn 9 + +" Create window splits easier. The default +" way is Ctrl-w,v and Ctrl-w,s. I remap +" this to vv and ss +nnoremap vv v +nnoremap ss s + +" Resize windows with arrow keys +nnoremap + +nnoremap - +nnoremap < +nnoremap > + +" ============================ +" Tabularize - alignment +" ============================ +" Hit Ctrl-Shift-A then type a character you want to align by +nmap :Tabularize / +vmap :Tabularize / + +" Source current file Ctrl-% (good for vim development) +map :so % diff --git a/vim/settings/yadr-keymap-mac.vim b/vim/settings/yadr-keymap-mac.vim new file mode 100644 index 0000000..73ab349 --- /dev/null +++ b/vim/settings/yadr-keymap-mac.vim @@ -0,0 +1,81 @@ +" ======================================== +" Mac specific General vim sanity improvements +" ======================================== +" +" ======================================== +" RSI Prevention - keyboard remaps +" ======================================== +" Certain things we do every day as programmers stress +" out our hands. For example, typing underscores and +" dashes are very common, and in position that require +" a lot of hand movement. Vim to the rescue +" +" Now using the middle finger of either hand you can type +" underscores with apple-k or apple-d, and add Shift +" to type dashes +imap _ +imap _ +imap - +imap - + +" Change inside various enclosures with Cmd-" and Cmd-' +" The f makes it find the enclosure so you don't have +" to be standing inside it +nnoremap f'ci' +nnoremap f"ci" +nnoremap f(ci( +nnoremap f)ci) +nnoremap f[ci[ +nnoremap f]ci] + +" ==== NERD tree +" Cmd-Shift-N for nerd tree +nmap :NERDTreeToggle + +" move up/down quickly by using Cmd-j, Cmd-k +" which will move us around by functions +nnoremap } +nnoremap { +autocmd FileType ruby map ]m +autocmd FileType ruby map [m +autocmd FileType rspec map } +autocmd FileType rspec map { +autocmd FileType javascript map } +autocmd FileType javascript map { + +" Command-/ to toggle comments +map :TComment +imap :TCommenti + +" Use numbers to pick the tab you want (like iTerm) +map :tabn 1 +map :tabn 2 +map :tabn 3 +map :tabn 4 +map :tabn 5 +map :tabn 6 +map :tabn 7 +map :tabn 8 +map :tabn 9 + +" Create window splits easier. The default +" way is Ctrl-w,v and Ctrl-w,s. I remap +" this to vv and ss +nnoremap vv v +nnoremap ss s + +" Resize windows with arrow keys +nnoremap + +nnoremap - +nnoremap < +nnoremap > + +" ============================ +" Tabularize - alignment +" ============================ +" Hit Cmd-Shift-A then type a character you want to align by +nmap :Tabularize / +vmap :Tabularize / + +" Source current file Cmd-% (good for vim development) +map :so % diff --git a/vim/settings/yadr-keymap.vim b/vim/settings/yadr-keymap.vim index 2c274a4..9cfde94 100644 --- a/vim/settings/yadr-keymap.vim +++ b/vim/settings/yadr-keymap.vim @@ -25,22 +25,6 @@ endfunction nnoremap 0 ^ nnoremap ^ 0 -" ======================================== -" RSI Prevention - keyboard remaps -" ======================================== -" Certain things we do every day as programmers stress -" out our hands. For example, typing underscores and -" dashes are very common, and in position that require -" a lot of hand movement. Vim to the rescue -" -" Now using the middle finger of either hand you can type -" underscores with apple-k or apple-d, and add Shift -" to type dashes -imap _ -imap _ -imap - -imap - - " ,# Surround a word with #{ruby interpolation} map ,# ysiw# vmap ,# c#{"} @@ -77,16 +61,6 @@ map ,` ysiw` " gary bernhardt's hashrocket imap => -" Change inside various enclosures with Cmd-" and Cmd-' -" The f makes it find the enclosure so you don't have -" to be standing inside it -nnoremap f'ci' -nnoremap f"ci" -nnoremap f(ci( -nnoremap f)ci) -nnoremap f[ci[ -nnoremap f]ci] - "Go to last edit location with ,. nnoremap ,. '. @@ -100,8 +74,6 @@ nnoremap ,. '. imap wa " ==== NERD tree -" Cmd-Shift-N for nerd tree -nmap :NERDTreeToggle " Open the project tree and expose current file in the nerdtree with Ctrl-\ nnoremap :NERDTreeFind:vertical res 30 @@ -110,23 +82,6 @@ nnoremap :NERDTreeFind:vertical res 30 nmap ,qc :cclose nmap ,qo :copen -" move up/down quickly by using Cmd-j, Cmd-k -" which will move us around by functions -nnoremap } -nnoremap { -autocmd FileType ruby map ]m -autocmd FileType ruby map [m -autocmd FileType rspec map } -autocmd FileType rspec map { -autocmd FileType javascript map } -autocmd FileType javascript map { - - -" Command-/ to toggle comments -map :TComment -imap :TCommenti - - "Move back and forth through previous and next buffers "with ,z and ,x nnoremap ,z :bp @@ -149,29 +104,12 @@ nnoremap gf :tabe " Zoom in map ,gz o -" Use numbers to pick the tab you want (like iTerm) -map :tabn 1 -map :tabn 2 -map :tabn 3 -map :tabn 4 -map :tabn 5 -map :tabn 6 -map :tabn 7 -map :tabn 8 -map :tabn 9 - " Create window splits easier. The default " way is Ctrl-w,v and Ctrl-w,s. I remap " this to vv and ss nnoremap vv v nnoremap ss s -" Resize windows with arrow keys -nnoremap + -nnoremap - -nnoremap < -nnoremap > - " create <%= foo %> erb tags using Ctrl-k in edit mode imap <%= %>3hi @@ -207,13 +145,6 @@ noremap ,hl :set hlsearch! hlsearch? nnoremap ' ` nnoremap ` ' -" ============================ -" Tabularize - alignment -" ============================ -" Hit Cmd-Shift-A then type a character you want to align by -nmap :Tabularize / -vmap :Tabularize / - " ============================ " SplitJoin plugin " ============================ @@ -223,8 +154,5 @@ nmap sk :SplitjoinJoin " Get the current highlight group. Useful for then remapping the color map ,hi :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" . " FG:" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"fg#") -" Source current file Cmd-% (good for vim development) -map :so % - " ,hp = html preview map ,hp :!open -a Safari %