aboutsummaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorJosh Rahm <rahm@google.com>2025-04-09 03:08:14 +0000
committerJosh Rahm <rahm@google.com>2025-04-09 03:08:14 +0000
commit94de573c7f05582cb2ab6e2a7cb81cca31ba6453 (patch)
treef857df98b5ac5cc69310c5be2ae49310e01f0064 /autoload
parent434fe773449e7bcaa7a233c02f06033188f51b79 (diff)
downloadfieldmarshal.vim-main.tar.gz
fieldmarshal.vim-main.tar.bz2
fieldmarshal.vim-main.zip
Add a vertical version of 'iw/iW' with iv/iVHEADmain
Diffstat (limited to 'autoload')
-rw-r--r--autoload/fall.vim44
1 files changed, 44 insertions, 0 deletions
diff --git a/autoload/fall.vim b/autoload/fall.vim
index feccc1a..ac54ba0 100644
--- a/autoload/fall.vim
+++ b/autoload/fall.vim
@@ -114,3 +114,47 @@ function! fall#visual_same_character(dir)
return expr
endfunction
+
+function! fall#visual_vertical_word(dir, def_class)
+ let start_line = line(".")
+ let line = start_line
+ let column = col(".")
+
+ let start_char = matchstr(getline(line), '\%' . column . 'c.')
+ if (start_char =~# '\s')
+ let class = '\s'
+ elseif (start_char =~# a:def_class)
+ let class = a:def_class
+ else
+ return ""
+ endif
+
+ let expr = ""
+
+ if a:dir =~ 'k'
+ while line > 1
+ let line -= 1
+ if ! (matchstr(getline(line), '\%' . column . 'c.') =~# class)
+ 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.') =~# class)
+ break
+ endif
+ let expr .= 'j'
+ endwhile
+ endif
+
+ return expr
+endfunction