Merge pull request #510 from nikolai-b/master
separate mac and linux vim keymaping
This commit is contained in:
commit
f6bdf5708e
14
README.md
14
README.md
@ -163,7 +163,7 @@ of plugins above to learn more.
|
||||
|
||||
* `,z` - go to previous buffer (:bp)
|
||||
* `,x` - go to next buffer (:bn)
|
||||
* `Cmd-j` and `Cmd-k` to move up and down roughly by functions
|
||||
* `Cmd-j` and `Cmd-k` to move up and down roughly by functions (`Alt` in Linux)
|
||||
* `Ctrl-o` - Old cursor position - this is a standard mapping but very useful, so included here
|
||||
* `Ctrl-i` - opposite of Ctrl-O (again, this is standard)
|
||||
|
||||
@ -193,7 +193,7 @@ of plugins above to learn more.
|
||||
* `,b` - CtrlP buffer selector - great for jumping to a file you already have open
|
||||
* `Cmd-Shift-M` - jump to method - CtrlP tag search within current buffer
|
||||
* `,jm` jump to models. Other `,j` mappings: `,jc` for controllers, `,jh` for helpers, etc. If you think of a concept and a letter, we've got you covered.
|
||||
* `Cmd-Shift-N` - NERDTree toggle
|
||||
* `Cmd-Shift-N` - NERDTree toggle (`Alt` in Linux)
|
||||
* `Ctrl-\` - Show current file in NERDTree
|
||||
* `Cmd-Shift-P` - Clear CtrlP cache
|
||||
|
||||
@ -201,13 +201,13 @@ of plugins above to learn more.
|
||||
|
||||
* Cmd-Space to autocomplete. Tab for snipmate snippets.
|
||||
* `,#` `,"` `,'` `,]` `,)` `,}` to surround a word in these common wrappers. the # does #{ruby interpolation}. works in visual mode (thanks @cj). Normally these are done with something like `ysw#`
|
||||
* `Cmd-'`, `Cmd-"`, `Cmd-]`, `Cmd-)`, etc to change content inside those surrounding marks. You don't have to be inside them.
|
||||
* `Cmd-'`, `Cmd-"`, `Cmd-]`, `Cmd-)`, etc to change content inside those surrounding marks. You don't have to be inside them (`Alt` in Linux)
|
||||
* `,.` to go to last edit location (same as `'.`) because the apostrophe is hard on the pinky
|
||||
* `,ci` to change inside any set of quotes/brackets/etc
|
||||
|
||||
#### Tabs, Windows, Splits
|
||||
|
||||
* Use `Cmd-1` thru `Cmd-9` to switch to a specific tab number (like iTerm and Chrome) - and tabs have been set up to show numbers
|
||||
* Use `Cmd-1` thru `Cmd-9` to switch to a specific tab number (like iTerm and Chrome) - and tabs have been set up to show numbers (`Alt` in Linux)
|
||||
* `Ctrl-h,l,j,k` - to move left, right, down, up between splits
|
||||
* `Q` - Intelligent Window Killer. Close window `wincmd c` if there are multiple windows to same buffer, or kill the buffer `bwipeout` if this is the last window into it.
|
||||
* `vv` - vertical split (`Ctrl-w,v`)
|
||||
@ -233,13 +233,13 @@ of plugins above to learn more.
|
||||
* `,he` - Html Escape
|
||||
* `,hu` - Html Unescape
|
||||
* `,hp` - Html Preview (open in Safari)
|
||||
* `Cmd-Shift-A` - align things (type a character/expression to align by, works in visual mode or by itself)
|
||||
* `Cmd-Shift-A` - align things (type a character/expression to align by, works in visual mode or by itself) (`Alt` in Linux)
|
||||
* `:ColorToggle` - turn on #abc123 color highlighting (useful for css)
|
||||
* `:Gitv` - Git log browsers
|
||||
* `,hi` - show current Highlight group. if you don't like the color of something, use this, then use `hi! link [groupname] [anothergroupname]` in your vimrc.after to remap the color. You can see available colors using `:hi`
|
||||
* `,gt` - Go Tidy - tidy up your html code (works on a visual selection)
|
||||
* `:Wrap` - wrap long lines (e.g. when editing markdown files).
|
||||
* `Cmd-/` - toggle comments (usually gcc from tComment)
|
||||
* `:Wrap` - wrap long lines (e.g. when editing markdown files)
|
||||
* `Cmd-/` - toggle comments (usually gcc from tComment) (`Alt` in Linux)
|
||||
* `gcp` (comment a paragraph)
|
||||
|
||||
#### Rails & Ruby
|
||||
|
5
Rakefile
5
Rakefile
@ -27,7 +27,7 @@ task :install => [:submodule_init, :submodules] do
|
||||
|
||||
Rake::Task["install_prezto"].execute
|
||||
|
||||
install_fonts if RUBY_PLATFORM.downcase.include?("darwin")
|
||||
install_fonts
|
||||
|
||||
install_term_theme if RUBY_PLATFORM.downcase.include?("darwin")
|
||||
|
||||
@ -181,7 +181,8 @@ def install_fonts
|
||||
puts "======================================================"
|
||||
puts "Installing patched fonts for Powerline/Lightline."
|
||||
puts "======================================================"
|
||||
run %{ cp -f $HOME/.yadr/fonts/* $HOME/Library/Fonts }
|
||||
run %{ cp -f $HOME/.yadr/fonts/* $HOME/Library/Fonts } if RUBY_PLATFORM.downcase.include?("darwin")
|
||||
run %{ mkdir -p ~/.fonts && cp ~/.yadr/fonts/* "$_" && fc-cache -vf ~/.fonts } if RUBY_PLATFORM.downcase.include?("linux")
|
||||
puts
|
||||
end
|
||||
|
||||
|
@ -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
|
||||
|
81
vim/settings/yadr-keymap-linux.vim
Normal file
81
vim/settings/yadr-keymap-linux.vim
Normal file
@ -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 Alt-k or Alt-d, and add Shift
|
||||
" to type dashes
|
||||
imap <silent> <A-k> _
|
||||
imap <silent> <A-d> _
|
||||
imap <silent> <A-K> -
|
||||
imap <silent> <A-D> -
|
||||
|
||||
" Change inside various enclosures with Alt-" and Alt-'
|
||||
" The f makes it find the enclosure so you don't have
|
||||
" to be standing inside it
|
||||
nnoremap <A-'> f'ci'
|
||||
nnoremap <A-"> f"ci"
|
||||
nnoremap <A-(> f(ci(
|
||||
nnoremap <A-)> f)ci)
|
||||
nnoremap <A-[> f[ci[
|
||||
nnoremap <A-]> f]ci]
|
||||
|
||||
" ==== NERD tree
|
||||
" Alt-Shift-N for nerd tree
|
||||
nmap <A-N> :NERDTreeToggle<CR>
|
||||
|
||||
" move up/down quickly by using Alt-j, Alt-k
|
||||
" which will move us around by functions
|
||||
nnoremap <silent> <A-j> }
|
||||
nnoremap <silent> <A-k> {
|
||||
autocmd FileType ruby map <buffer> <A-j> ]m
|
||||
autocmd FileType ruby map <buffer> <A-k> [m
|
||||
autocmd FileType rspec map <buffer> <A-j> }
|
||||
autocmd FileType rspec map <buffer> <A-k> {
|
||||
autocmd FileType javascript map <buffer> <A-k> }
|
||||
autocmd FileType javascript map <buffer> <A-j> {
|
||||
|
||||
" Command-/ to toggle comments
|
||||
map <A-/> :TComment<CR>
|
||||
imap <A-/> <Esc>:TComment<CR>i
|
||||
|
||||
" Use Alt- numbers to pick the tab you want
|
||||
map <silent> <A-1> :tabn 1<cr>
|
||||
map <silent> <A-2> :tabn 2<cr>
|
||||
map <silent> <A-3> :tabn 3<cr>
|
||||
map <silent> <A-4> :tabn 4<cr>
|
||||
map <silent> <A-5> :tabn 5<cr>
|
||||
map <silent> <A-6> :tabn 6<cr>
|
||||
map <silent> <A-7> :tabn 7<cr>
|
||||
map <silent> <A-8> :tabn 8<cr>
|
||||
map <silent> <A-9> :tabn 9<cr>
|
||||
|
||||
" Create window splits easier. The default
|
||||
" way is Ctrl-w,v and Ctrl-w,s. I remap
|
||||
" this to vv and ss
|
||||
nnoremap <silent> vv <C-w>v
|
||||
nnoremap <silent> ss <C-w>s
|
||||
|
||||
" Resize windows with arrow keys
|
||||
nnoremap <C-Up> <C-w>+
|
||||
nnoremap <C-Down> <C-w>-
|
||||
nnoremap <C-Left> <C-w><
|
||||
nnoremap <C-Right> <C-w>>
|
||||
|
||||
" ============================
|
||||
" Tabularize - alignment
|
||||
" ============================
|
||||
" Hit Alt-Shift-A then type a character you want to align by
|
||||
nmap <A-A> :Tabularize /
|
||||
vmap <A-A> :Tabularize /
|
||||
|
||||
" Source current file Alt-% (good for vim development)
|
||||
map <A-%> :so %<CR>
|
81
vim/settings/yadr-keymap-mac.vim
Normal file
81
vim/settings/yadr-keymap-mac.vim
Normal file
@ -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 <silent> <D-k> _
|
||||
imap <silent> <D-d> _
|
||||
imap <silent> <D-K> -
|
||||
imap <silent> <D-D> -
|
||||
|
||||
" 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 <D-'> f'ci'
|
||||
nnoremap <D-"> f"ci"
|
||||
nnoremap <D-(> f(ci(
|
||||
nnoremap <D-)> f)ci)
|
||||
nnoremap <D-[> f[ci[
|
||||
nnoremap <D-]> f]ci]
|
||||
|
||||
" ==== NERD tree
|
||||
" Cmd-Shift-N for nerd tree
|
||||
nmap <D-N> :NERDTreeToggle<CR>
|
||||
|
||||
" move up/down quickly by using Cmd-j, Cmd-k
|
||||
" which will move us around by functions
|
||||
nnoremap <silent> <D-j> }
|
||||
nnoremap <silent> <D-k> {
|
||||
autocmd FileType ruby map <buffer> <D-j> ]m
|
||||
autocmd FileType ruby map <buffer> <D-k> [m
|
||||
autocmd FileType rspec map <buffer> <D-j> }
|
||||
autocmd FileType rspec map <buffer> <D-k> {
|
||||
autocmd FileType javascript map <buffer> <D-k> }
|
||||
autocmd FileType javascript map <buffer> <D-j> {
|
||||
|
||||
" Command-/ to toggle comments
|
||||
map <D-/> :TComment<CR>
|
||||
imap <D-/> <Esc>:TComment<CR>i
|
||||
|
||||
" Use numbers to pick the tab you want (like iTerm)
|
||||
map <silent> <D-1> :tabn 1<cr>
|
||||
map <silent> <D-2> :tabn 2<cr>
|
||||
map <silent> <D-3> :tabn 3<cr>
|
||||
map <silent> <D-4> :tabn 4<cr>
|
||||
map <silent> <D-5> :tabn 5<cr>
|
||||
map <silent> <D-6> :tabn 6<cr>
|
||||
map <silent> <D-7> :tabn 7<cr>
|
||||
map <silent> <D-8> :tabn 8<cr>
|
||||
map <silent> <D-9> :tabn 9<cr>
|
||||
|
||||
" Create window splits easier. The default
|
||||
" way is Ctrl-w,v and Ctrl-w,s. I remap
|
||||
" this to vv and ss
|
||||
nnoremap <silent> vv <C-w>v
|
||||
nnoremap <silent> ss <C-w>s
|
||||
|
||||
" Resize windows with arrow keys
|
||||
nnoremap <D-Up> <C-w>+
|
||||
nnoremap <D-Down> <C-w>-
|
||||
nnoremap <D-Left> <C-w><
|
||||
nnoremap <D-Right> <C-w>>
|
||||
|
||||
" ============================
|
||||
" Tabularize - alignment
|
||||
" ============================
|
||||
" Hit Cmd-Shift-A then type a character you want to align by
|
||||
nmap <D-A> :Tabularize /
|
||||
vmap <D-A> :Tabularize /
|
||||
|
||||
" Source current file Cmd-% (good for vim development)
|
||||
map <D-%> :so %<CR>
|
@ -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 <silent> <D-k> _
|
||||
imap <silent> <D-d> _
|
||||
imap <silent> <D-K> -
|
||||
imap <silent> <D-D> -
|
||||
|
||||
" ,# Surround a word with #{ruby interpolation}
|
||||
map ,# ysiw#
|
||||
vmap ,# c#{<C-R>"}<ESC>
|
||||
@ -77,16 +61,6 @@ map ,` ysiw`
|
||||
" gary bernhardt's hashrocket
|
||||
imap <c-l> <space>=><space>
|
||||
|
||||
" 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 <D-'> f'ci'
|
||||
nnoremap <D-"> f"ci"
|
||||
nnoremap <D-(> f(ci(
|
||||
nnoremap <D-)> f)ci)
|
||||
nnoremap <D-[> f[ci[
|
||||
nnoremap <D-]> f]ci]
|
||||
|
||||
"Go to last edit location with ,.
|
||||
nnoremap ,. '.
|
||||
|
||||
@ -100,8 +74,6 @@ nnoremap ,. '.
|
||||
imap <C-a> <esc>wa
|
||||
|
||||
" ==== NERD tree
|
||||
" Cmd-Shift-N for nerd tree
|
||||
nmap <D-N> :NERDTreeToggle<CR>
|
||||
" Open the project tree and expose current file in the nerdtree with Ctrl-\
|
||||
nnoremap <silent> <C-\> :NERDTreeFind<CR>:vertical res 30<CR>
|
||||
|
||||
@ -110,23 +82,6 @@ nnoremap <silent> <C-\> :NERDTreeFind<CR>:vertical res 30<CR>
|
||||
nmap <silent> ,qc :cclose<CR>
|
||||
nmap <silent> ,qo :copen<CR>
|
||||
|
||||
" move up/down quickly by using Cmd-j, Cmd-k
|
||||
" which will move us around by functions
|
||||
nnoremap <silent> <D-j> }
|
||||
nnoremap <silent> <D-k> {
|
||||
autocmd FileType ruby map <buffer> <D-j> ]m
|
||||
autocmd FileType ruby map <buffer> <D-k> [m
|
||||
autocmd FileType rspec map <buffer> <D-j> }
|
||||
autocmd FileType rspec map <buffer> <D-k> {
|
||||
autocmd FileType javascript map <buffer> <D-k> }
|
||||
autocmd FileType javascript map <buffer> <D-j> {
|
||||
|
||||
|
||||
" Command-/ to toggle comments
|
||||
map <D-/> :TComment<CR>
|
||||
imap <D-/> <Esc>:TComment<CR>i
|
||||
|
||||
|
||||
"Move back and forth through previous and next buffers
|
||||
"with ,z and ,x
|
||||
nnoremap <silent> ,z :bp<CR>
|
||||
@ -149,29 +104,12 @@ nnoremap <C-w>gf :tabe<cfile><CR>
|
||||
" Zoom in
|
||||
map <silent> ,gz <C-w>o
|
||||
|
||||
" Use numbers to pick the tab you want (like iTerm)
|
||||
map <silent> <D-1> :tabn 1<cr>
|
||||
map <silent> <D-2> :tabn 2<cr>
|
||||
map <silent> <D-3> :tabn 3<cr>
|
||||
map <silent> <D-4> :tabn 4<cr>
|
||||
map <silent> <D-5> :tabn 5<cr>
|
||||
map <silent> <D-6> :tabn 6<cr>
|
||||
map <silent> <D-7> :tabn 7<cr>
|
||||
map <silent> <D-8> :tabn 8<cr>
|
||||
map <silent> <D-9> :tabn 9<cr>
|
||||
|
||||
" Create window splits easier. The default
|
||||
" way is Ctrl-w,v and Ctrl-w,s. I remap
|
||||
" this to vv and ss
|
||||
nnoremap <silent> vv <C-w>v
|
||||
nnoremap <silent> ss <C-w>s
|
||||
|
||||
" Resize windows with arrow keys
|
||||
nnoremap <D-Up> <C-w>+
|
||||
nnoremap <D-Down> <C-w>-
|
||||
nnoremap <D-Left> <C-w><
|
||||
nnoremap <D-Right> <C-w>>
|
||||
|
||||
" create <%= foo %> erb tags using Ctrl-k in edit mode
|
||||
imap <silent> <C-K> <%= %><Esc>3hi
|
||||
|
||||
@ -207,13 +145,6 @@ noremap ,hl :set hlsearch! hlsearch?<CR>
|
||||
nnoremap ' `
|
||||
nnoremap ` '
|
||||
|
||||
" ============================
|
||||
" Tabularize - alignment
|
||||
" ============================
|
||||
" Hit Cmd-Shift-A then type a character you want to align by
|
||||
nmap <D-A> :Tabularize /
|
||||
vmap <D-A> :Tabularize /
|
||||
|
||||
" ============================
|
||||
" SplitJoin plugin
|
||||
" ============================
|
||||
@ -223,8 +154,5 @@ nmap sk :SplitjoinJoin<cr>
|
||||
" 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#")<CR>
|
||||
|
||||
" Source current file Cmd-% (good for vim development)
|
||||
map <D-%> :so %<CR>
|
||||
|
||||
" ,hp = html preview
|
||||
map <silent> ,hp :!open -a Safari %<CR><CR>
|
||||
|
Loading…
Reference in New Issue
Block a user