aboutsummaryrefslogtreecommitdiff
path: root/autoload/fall.vim
diff options
context:
space:
mode:
Diffstat (limited to 'autoload/fall.vim')
-rw-r--r--autoload/fall.vim38
1 files changed, 37 insertions, 1 deletions
diff --git a/autoload/fall.vim b/autoload/fall.vim
index 493ded3..feccc1a 100644
--- a/autoload/fall.vim
+++ b/autoload/fall.vim
@@ -77,4 +77,40 @@ function! fall#fall(dir, pattern) abort
endwhile
return "m'" . n . a:dir
-endfunction!
+endfunction
+
+function! fall#visual_same_character(dir)
+ let start_line = line(".")
+ let line = start_line
+ let column = col(".")
+ let char_to_match = matchstr(getline(line), '\%' . column . 'c.')
+
+ let expr = ""
+
+ if a:dir =~ 'k'
+ while line > 1
+ let line -= 1
+ if matchstr(getline(line), '\%' . column . 'c.') != char_to_match
+ break
+ endif
+ let expr .= 'k'
+ endwhile
+ endif
+
+ if a:dir == 'jk'
+ let expr .= 'o'
+ let line = start_line
+ endif
+
+ if a:dir =~ 'j'
+ while line <= line("$")
+ let line += 1
+ if matchstr(getline(line), '\%' . column . 'c.') != char_to_match
+ break
+ endif
+ let expr .= 'j'
+ endwhile
+ endif
+
+ return expr
+endfunction