diff options
| author | Josh Rahm <rahm@google.com> | 2024-03-08 19:34:20 +0000 |
|---|---|---|
| committer | Josh Rahm <rahm@google.com> | 2024-03-08 19:34:20 +0000 |
| commit | fd5de6e1630c9e3a5966eb4101e376863676e58d (patch) | |
| tree | b6d483804abee1d6888e2e77819755877c332f12 /autoload/fall.vim | |
| parent | c8ef92cfb59f28c050b82e90fb813d25392e6664 (diff) | |
| download | fieldmarshal.vim-fd5de6e1630c9e3a5966eb4101e376863676e58d.tar.gz fieldmarshal.vim-fd5de6e1630c9e3a5966eb4101e376863676e58d.tar.bz2 fieldmarshal.vim-fd5de6e1630c9e3a5966eb4101e376863676e58d.zip | |
Bunch of changes.
Salient changes are:
Get rid of object remapping the quotes (i/a "/'/`) in favor of adding
a new text object "next quotes" such as cin"/can"/etc.
Added mappings in visual mode that behave like "fall", but for
matching characters. So <C-v>ic will highlight the current character
and all of the same character up and down. Super useful for making
edits to columns of identical characters.
Added a text object ic/ac that highlight all the lines that match.
removed the uncommented paragraph text objects as they're broken
anyway.
Diffstat (limited to 'autoload/fall.vim')
| -rw-r--r-- | autoload/fall.vim | 38 |
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 |