" EasyMotion - Vim motions on speed! " " Author: Kim Silkebækken " haya14busa " Source: https://github.com/Lokaltog/vim-easymotion " Last Change: 13 Feb 2014. " == Script initialization {{{ if expand("%:p") ==# expand(":p") unlet! g:EasyMotion_loaded endif if exists('g:EasyMotion_loaded') || &compatible || version < 703 finish endif let g:EasyMotion_loaded = 1 " }}} " == Saving 'cpoptions' {{{ let s:save_cpo = &cpo set cpo&vim " }}} " == Default configuration {{{ " -- Option ------------------------------ {{{ let g:EasyMotion_keys = get(g:, \ 'EasyMotion_keys', 'asdghklqwertyuiopzxcvbnmfj;') " \ 'EasyMotion_keys', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') let g:EasyMotion_do_mapping = get(g: , 'EasyMotion_do_mapping' , 1) let g:EasyMotion_do_shade = get(g: , 'EasyMotion_do_shade' , 1) let g:EasyMotion_grouping = get(g: , 'EasyMotion_grouping' , 1) let g:EasyMotion_startofline = get(g: , 'EasyMotion_startofline' , 1) let g:EasyMotion_smartcase = get(g: , 'EasyMotion_smartcase' , 0) let g:EasyMotion_skipfoldedline = get(g: , 'EasyMotion_skipfoldedline' , 1) let g:EasyMotion_use_migemo = get(g: , 'EasyMotion_use_migemo' , 0) let g:EasyMotion_use_upper = get(g: , 'EasyMotion_use_upper' , 0) let g:EasyMotion_enter_jump_first = get(g: , 'EasyMotion_enter_jump_first' , 0) let g:EasyMotion_space_jump_first = get(g: , 'EasyMotion_space_jump_first' , 0) let g:EasyMotion_inc_highlight = get(g: , 'EasyMotion_inc_highlight' , 1) let g:EasyMotion_move_highlight = get(g: , 'EasyMotion_move_highlight' , 1) let g:EasyMotion_landing_highlight = get(g: , 'EasyMotion_landing_highlight' , 0) let g:EasyMotion_cursor_highlight = get(g: , 'EasyMotion_cursor_highlight' , 0) let g:EasyMotion_use_regexp = get(g: , 'EasyMotion_use_regexp' , 1) let g:EasyMotion_add_search_history = get(g: , 'EasyMotion_add_search_history' , 1) let g:EasyMotion_off_screen_search = get(g: , 'EasyMotion_off_screen_search' , 1) let g:EasyMotion_force_csapprox = get(g: , 'EasyMotion_force_csapprox' , 0) let g:EasyMotion_show_prompt = get(g: , 'EasyMotion_show_prompt' , 1) let g:EasyMotion_prompt = \ get(g: , 'EasyMotion_prompt' , 'Search for {n} character(s): ') let g:EasyMotion_command_line_key_mappings = \ get(g: , 'EasyMotion_command_line_key_mappings' , {}) "}}} " }}} " == Mapping {{{ " Note: bd is short for bidirectional " l is short for (within) line function! s:find_motion_map_helper(motions) "{{{ for [name, dict] in items(a:motions) silent exec 'noremap (easymotion-'.name.')' . \ ' :call EasyMotion#'. dict.fnc .'('. dict.cnt .',0,'. dict.direction .')' silent exec 'xnoremap (easymotion-'.name.')' . \ ' :call EasyMotion#'. dict.fnc .'('. dict.cnt .',1,'. dict.direction .')' " Example: " noremap (easymotion-f2) :call EasyMotion#S(2,1,0) " xnoremap (easymotion-f2) :call EasyMotion#S(2,1,0) endfor endfunction "}}} " Find Motion: {{{ call s:find_motion_map_helper({ \ 'f' : {'fnc': 'S' , 'cnt': 1, 'direction': 0}, \ 'F' : {'fnc': 'S' , 'cnt': 1, 'direction': 1}, \ 's' : {'fnc': 'S' , 'cnt': 1, 'direction': 2}, \ 'bd-f' : {'fnc': 'S' , 'cnt': 1, 'direction': 2}, \ 't' : {'fnc': 'T' , 'cnt': 1, 'direction': 0}, \ 'T' : {'fnc': 'T' , 'cnt': 1, 'direction': 1}, \ 'bd-t' : {'fnc': 'T', 'cnt': 1, 'direction': 2}, \ 'fl' : {'fnc': 'SL', 'cnt': 1, 'direction': 0}, \ 'Fl' : {'fnc': 'SL', 'cnt': 1, 'direction': 1}, \ 'sl' : {'fnc': 'SL', 'cnt': 1, 'direction': 2}, \ 'bd-fl' : {'fnc': 'SL', 'cnt': 1, 'direction': 2}, \ 'tl' : {'fnc': 'TL', 'cnt': 1, 'direction': 0}, \ 'Tl' : {'fnc': 'TL', 'cnt': 1, 'direction': 1}, \ 'bd-tl' : {'fnc': 'TL', 'cnt': 1, 'direction': 2}, \ \ 'f2' : {'fnc': 'S' , 'cnt': 2, 'direction': 0}, \ 'F2' : {'fnc': 'S' , 'cnt': 2, 'direction': 1}, \ 's2' : {'fnc': 'S' , 'cnt': 2, 'direction': 2}, \ 'bd-f2' : {'fnc': 'S' , 'cnt': 2, 'direction': 2}, \ 't2' : {'fnc': 'T' , 'cnt': 2, 'direction': 0}, \ 'T2' : {'fnc': 'T' , 'cnt': 2, 'direction': 1}, \ 'bd-t2' : {'fnc': 'T', 'cnt': 2, 'direction': 2}, \ 'fl2' : {'fnc': 'SL', 'cnt': 2, 'direction': 0}, \ 'Fl2' : {'fnc': 'SL', 'cnt': 2, 'direction': 1}, \ 'sl2' : {'fnc': 'SL', 'cnt': 2, 'direction': 2}, \ 'bd-fl2' : {'fnc': 'SL', 'cnt': 2, 'direction': 2}, \ 'tl2' : {'fnc': 'TL', 'cnt': 2, 'direction': 0}, \ 'Tl2' : {'fnc': 'TL', 'cnt': 2, 'direction': 1}, \ 'bd-tl2' : {'fnc': 'TL', 'cnt': 2, 'direction': 2}, \ \ 'fn' : {'fnc': 'S' , 'cnt': -1, 'direction': 0}, \ 'Fn' : {'fnc': 'S' , 'cnt': -1, 'direction': 1}, \ 'sn' : {'fnc': 'S' , 'cnt': -1, 'direction': 2}, \ 'bd-fn' : {'fnc': 'S' , 'cnt': -1, 'direction': 2}, \ 'tn' : {'fnc': 'T' , 'cnt': -1, 'direction': 0}, \ 'Tn' : {'fnc': 'T' , 'cnt': -1, 'direction': 1}, \ 'bd-tn' : {'fnc': 'T', 'cnt': -1, 'direction': 2}, \ 'fln' : {'fnc': 'SL', 'cnt': -1, 'direction': 0}, \ 'Fln' : {'fnc': 'SL', 'cnt': -1, 'direction': 1}, \ 'sln' : {'fnc': 'SL', 'cnt': -1, 'direction': 2}, \ 'bd-fln' : {'fnc': 'SL', 'cnt': -1, 'direction': 2}, \ 'tln' : {'fnc': 'TL', 'cnt': -1, 'direction': 0}, \ 'Tln' : {'fnc': 'TL', 'cnt': -1, 'direction': 1}, \ 'bd-tln' : {'fnc': 'TL', 'cnt': -1, 'direction': 2}, \ }) "}}} " -- Word Motion {{{ " Word: {{{ noremap (easymotion-w) :call EasyMotion#WB(0,0) xnoremap (easymotion-w) :call EasyMotion#WB(1,0) noremap (easymotion-b) :call EasyMotion#WB(0,1) xnoremap (easymotion-b) :call EasyMotion#WB(1,1) noremap (easymotion-bd-w) :call EasyMotion#WB(0,2) xnoremap (easymotion-bd-w) :call EasyMotion#WB(1,2) "}}} " WORD: {{{ noremap (easymotion-W) :call EasyMotion#WBW(0,0) xnoremap (easymotion-W) :call EasyMotion#WBW(1,0) noremap (easymotion-B) :call EasyMotion#WBW(0,1) xnoremap (easymotion-B) :call EasyMotion#WBW(1,1) noremap (easymotion-bd-W) :call EasyMotion#WBW(0,2) xnoremap (easymotion-bd-W) :call EasyMotion#WBW(1,2) "}}} " iskeyword {{{ noremap (easymotion-iskeyword-w) :call EasyMotion#WBK(0,0) xnoremap (easymotion-iskeyword-w) :call EasyMotion#WBK(1,0) noremap (easymotion-iskeyword-b) :call EasyMotion#WBK(0,1) xnoremap (easymotion-iskeyword-b) :call EasyMotion#WBK(1,1) noremap (easymotion-iskeyword-bd-w) :call EasyMotion#WBK(0,2) xnoremap (easymotion-iskeyword-bd-w) :call EasyMotion#WBK(1,2) " }}} " End Word: {{{ noremap (easymotion-e) :call EasyMotion#E(0,0) xnoremap (easymotion-e) :call EasyMotion#E(1,0) noremap (easymotion-ge) :call EasyMotion#E(0,1) xnoremap (easymotion-ge) :call EasyMotion#E(1,1) noremap (easymotion-bd-e) :call EasyMotion#E(0,2) xnoremap (easymotion-bd-e) :call EasyMotion#E(1,2) "}}} " END WORD: {{{ noremap (easymotion-E) :call EasyMotion#EW(0,0) xnoremap (easymotion-E) :call EasyMotion#EW(1,0) noremap (easymotion-gE) :call EasyMotion#EW(0,1) xnoremap (easymotion-gE) :call EasyMotion#EW(1,1) noremap (easymotion-bd-E) :call EasyMotion#EW(0,2) xnoremap (easymotion-bd-E) :call EasyMotion#EW(1,2) "}}} " iskeyword End: {{{ noremap (easymotion-iskeyword-e) :call EasyMotion#EK(0,0) xnoremap (easymotion-iskeyword-e) :call EasyMotion#EK(1,0) noremap (easymotion-iskeyword-ge) :call EasyMotion#EK(0,1) xnoremap (easymotion-iskeyword-ge) :call EasyMotion#EK(1,1) noremap (easymotion-iskeyword-bd-e) :call EasyMotion#EK(0,2) xnoremap (easymotion-iskeyword-bd-e) :call EasyMotion#EK(1,2) "}}} "}}} " -- JK Motion {{{ noremap (easymotion-j) :call EasyMotion#JK(0,0) xnoremap (easymotion-j) :call EasyMotion#JK(1,0) noremap (easymotion-k) :call EasyMotion#JK(0,1) xnoremap (easymotion-k) :call EasyMotion#JK(1,1) noremap (easymotion-bd-jk) :call EasyMotion#JK(0,2) xnoremap (easymotion-bd-jk) :call EasyMotion#JK(1,2) " Start of Line JK {{{ noremap (easymotion-sol-j) :call EasyMotion#Sol(0,0) xnoremap (easymotion-sol-j) :call EasyMotion#Sol(1,0) noremap (easymotion-sol-k) :call EasyMotion#Sol(0,1) xnoremap (easymotion-sol-k) :call EasyMotion#Sol(1,1) noremap (easymotion-sol-bd-jk) :call EasyMotion#Sol(0,2) xnoremap (easymotion-sol-bd-jk) :call EasyMotion#Sol(1,2) "}}} " End of Line JK {{{ noremap (easymotion-eol-j) :call EasyMotion#Eol(0,0) xnoremap (easymotion-eol-j) :call EasyMotion#Eol(1,0) noremap (easymotion-eol-k) :call EasyMotion#Eol(0,1) xnoremap (easymotion-eol-k) :call EasyMotion#Eol(1,1) noremap (easymotion-eol-bd-jk) :call EasyMotion#Eol(0,2) xnoremap (easymotion-eol-bd-jk) :call EasyMotion#Eol(1,2) "}}} "}}} " -- Search Motion {{{ noremap (easymotion-n) :call EasyMotion#Search(0,0) xnoremap (easymotion-n) :call EasyMotion#Search(1,0) noremap (easymotion-N) :call EasyMotion#Search(0,1) xnoremap (easymotion-N) :call EasyMotion#Search(1,1) noremap (easymotion-bd-n) :call EasyMotion#Search(0,2) xnoremap (easymotion-bd-n) :call EasyMotion#Search(1,2) "}}} " -- Jump To Anywhere Motion {{{ noremap (easymotion-jumptoanywhere) \ :call EasyMotion#JumpToAnywhere(0,2) xnoremap (easymotion-jumptoanywhere) \ :call EasyMotion#JumpToAnywhere(1,2) "}}} " -- Repeat Motion {{{ noremap (easymotion-repeat) \ :call EasyMotion#Repeat(0) xnoremap (easymotion-repeat) \ :call EasyMotion#Repeat(1) noremap (easymotion-dotrepeat) \ :call EasyMotion#DotRepeat(0) xnoremap (easymotion-dotrepeat) \ :call EasyMotion#DotRepeat(1) "}}} " -- Next,Previous Motion {{{ noremap (easymotion-next) \ :call EasyMotion#NextPrevious(0,0) xnoremap (easymotion-next) \ :call EasyMotion#NextPrevious(1,0) noremap (easymotion-prev) \ :call EasyMotion#NextPrevious(0,1) xnoremap (easymotion-prev) \ :call EasyMotion#NextPrevious(1,1) "}}} " -- Line Motion {{{ " Word Line: {{{ noremap (easymotion-wl) :call EasyMotion#WBL(0,0) xnoremap (easymotion-wl) :call EasyMotion#WBL(1,0) noremap (easymotion-bl) :call EasyMotion#WBL(0,1) xnoremap (easymotion-bl) :call EasyMotion#WBL(1,1) noremap (easymotion-bd-wl) :call EasyMotion#WBL(0,2) xnoremap (easymotion-bd-wl) :call EasyMotion#WBL(1,2) "}}} " End Word Line: {{{ noremap (easymotion-el) :call EasyMotion#EL(0,0) xnoremap (easymotion-el) :call EasyMotion#EL(1,0) noremap (easymotion-gel) :call EasyMotion#EL(0,1) xnoremap (easymotion-gel) :call EasyMotion#EL(1,1) noremap (easymotion-bd-el) :call EasyMotion#EL(0,2) xnoremap (easymotion-bd-el) :call EasyMotion#EL(1,2) "}}} " LineAnywhere Line: {{{ noremap (easymotion-lineforward) \ :call EasyMotion#LineAnywhere(0,0) xnoremap (easymotion-lineforward) \ :call EasyMotion#LineAnywhere(1,0) noremap (easymotion-linebackward) \ :call EasyMotion#LineAnywhere(0,1) xnoremap (easymotion-linebackward) \ :call EasyMotion#LineAnywhere(1,1) noremap (easymotion-lineanywhere) \ :call EasyMotion#LineAnywhere(0,2) xnoremap (easymotion-lineanywhere) \ :call EasyMotion#LineAnywhere(1,2) "}}} "}}} noremap (easymotion-activate) :call EasyMotion#activate(0) xnoremap (easymotion-activate) :call EasyMotion#activate(1) " }}} " == Default key mapping {{{ if g:EasyMotion_do_mapping == 1 " Prepare Prefix: {{{ if exists('g:EasyMotion_leader_key') exec 'map ' . g:EasyMotion_leader_key . ' (easymotion-prefix)' else if !hasmapto('(easymotion-prefix)') map (easymotion-prefix) endif endif "}}} function! s:default_mapping(motions, do_mapping) "{{{ for [motion, fn] in items(a:motions) " Mapping {{{ if exists('g:EasyMotion_mapping_' . motion) " Backward compatible mapping [deprecated] silent exec 'map ' . \ eval('g:EasyMotion_mapping_' . motion) . ' (easymotion-' . motion . ')' elseif a:do_mapping \ && !hasmapto('(easymotion-' . motion . ')') \ && empty(maparg('(easymotion-prefix)' . motion, 'nov')) " Do mapping silent exec 'map ' . \'(easymotion-prefix)' . motion . ' (easymotion-' . motion . ')' endif "}}} endfor endfunction "}}} " Default Mapping: call s:default_mapping({ \ 'f' : { 'name': 'S' , 'dir': 0 } \ , 'F' : { 'name': 'S' , 'dir': 1 } \ , 's' : { 'name': 'S' , 'dir': 2 } \ , 't' : { 'name': 'T' , 'dir': 0 } \ , 'T' : { 'name': 'T' , 'dir': 1 } \ , 'w' : { 'name': 'WB' , 'dir': 0 } \ , 'W' : { 'name': 'WBW' , 'dir': 0 } \ , 'b' : { 'name': 'WB' , 'dir': 1 } \ , 'B' : { 'name': 'WBW' , 'dir': 1 } \ , 'e' : { 'name': 'E' , 'dir': 0 } \ , 'E' : { 'name': 'EW' , 'dir': 0 } \ , 'ge': { 'name': 'E' , 'dir': 1 } \ , 'gE': { 'name': 'EW' , 'dir': 1 } \ , 'j' : { 'name': 'JK' , 'dir': 0 } \ , 'k' : { 'name': 'JK' , 'dir': 1 } \ , 'n' : { 'name': 'Search' , 'dir': 0 } \ , 'N' : { 'name': 'Search' , 'dir': 1 } \ }, g:EasyMotion_do_mapping) endif "}}} " == CommandLine Mapping {{{ command! -nargs=* \ EMCommandLineNoreMap \ call EasyMotion#command_line#cnoremap([]) command! -nargs=* \ EMCommandLineMap \ call EasyMotion#command_line#cmap([]) command! -nargs=1 \ EMCommandLineUnMap \ call EasyMotion#command_line#cunmap() "}}} " == Restore 'cpoptions' {{{ let &cpo = s:save_cpo unlet s:save_cpo " }}} " vim: fdm=marker:et:ts=4:sw=4:sts=4