Skip to content

Commit

Permalink
Merge branch 'feature/up-down-motions' into develop
Browse files Browse the repository at this point in the history
* feature/up-down-motions:
  Update docs
  Add doc note about line jumping bug
  Add j/k motions
  Check if lines are empty before substituting
  • Loading branch information
Lokaltog committed Mar 30, 2011
2 parents f14c962 + 7206d65 commit 527cb02
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
5 changes: 4 additions & 1 deletion doc/easymotion.txt
Expand Up @@ -124,6 +124,8 @@ mode:
<Leader>e See |e|
<Leader>b See |b|
<Leader>ge See |ge|
<Leader>j See |j|
<Leader>k See |k|

Default: 1

Expand All @@ -140,7 +142,8 @@ http://creativecommons.org/licenses/by-sa/3.0/
==============================================================================
6. Known bugs *easymotion-known-bugs*

None.
- Lines jump to the left when usin j/k motions when a line is prepended
by a hard tab due to the tab being replaced with the marker character.

==============================================================================
7. Contributing *easymotion-contributing*
Expand Down
20 changes: 18 additions & 2 deletions plugin/EasyMotion.vim
Expand Up @@ -61,6 +61,12 @@
nnoremap <silent> <Leader>ge :call EasyMotionE(0, 1)<CR>
vnoremap <silent> <Leader>ge :<C-U>call EasyMotionE(1, 1)<CR>
nnoremap <silent> <Leader>j :call EasyMotionJK(0, 0)<CR>
vnoremap <silent> <Leader>j :<C-U>call EasyMotionJK(1, 0)<CR>
nnoremap <silent> <Leader>k :call EasyMotionJK(0, 1)<CR>
vnoremap <silent> <Leader>k :<C-U>call EasyMotionJK(1, 1)<CR>
endif
" }}}
" Initialize variables {{{
Expand Down Expand Up @@ -110,6 +116,9 @@
function! EasyMotionE(visualmode, direction) " {{{
call s:EasyMotion('.\>', a:direction, a:visualmode ? visualmode() : '')
endfunction " }}}
function! EasyMotionJK(visualmode, direction) " {{{
call s:EasyMotion('\%1v', a:direction, a:visualmode ? visualmode() : '')
endfunction " }}}
" }}}
" Helper functions {{{
function! s:Message(message) " {{{
Expand Down Expand Up @@ -207,8 +216,15 @@
let lines[line_num] = { 'orig': current_line, 'marker': current_line }
endif

" Substitute marker character
let lines[line_num]['marker'] = substitute(lines[line_num]['marker'], '\%' . col_num . 'c.', s:index_to_key[single_group ? element : current_group], '')
let marker_char = s:index_to_key[single_group ? element : current_group]

if strlen(lines[line_num]['marker']) > 0
" Substitute marker character if line length > 0
let lines[line_num]['marker'] = substitute(lines[line_num]['marker'], '\%' . col_num . 'c.', marker_char, '')
else
" Set the line to the marker character if the line is empty
let lines[line_num]['marker'] = marker_char
endif

" Add highlighting coordinates
call add(hl_coords, '\%' . line_num . 'l\%' . col_num . 'c')
Expand Down

0 comments on commit 527cb02

Please sign in to comment.