Greg Hurrell [Fri, 3 Dec 2021 10:23:19 +0000 (11:23 +0100)]
fix: also work with long forms of `:v` (`:vg` ... `:vglobal`)
Don't know what I was thinking, but I didn't ship the complete fix in a0057f55c0e8c3067811c4e1ce4e2f1eb2ea8e57. This commit adds this missing
forms of the `:v` command.
Greg Hurrell [Thu, 2 Dec 2021 21:47:43 +0000 (22:47 +0100)]
fix: make `:g!` work as a command
This is a little bit subtle, but I tried to explain it in the comments.
Turns out that `:g!` (and `:gl!`, `:glo!` ... `:global!`) is a command,
equivalent to `:v`, and Vim _does not_ treat the `!` as a slash
delimiter. This means that the old behavior was wrong; we would see `!`
after the `:g`, assume it was a delimiter, and append `!\v`. Instead,
what we need to do, is leave it unexpanded and wait for the user to
input a slash (or other delimiter).
Summarizing - standard usage with a slash:
- `:g/foo/d` means "delete all lines matching foo".
- `:v/foo/d` means "delete all lines not matching foo".
- `:s/foo/bar/` means "replace foo with bar".
And you can use lots of other symbols in lieu of slash, like "#":
- `:g#foo#d` means "delete all lines matching foo".
- `:v#foo#d` means "delete all lines not matching foo".
- `:s#foo#bar#` means "replace foo with bar".
But "!" is special, because sometimes it indicates a bang form of a
command and other times it can stand in for slash:
- `:g!/foo/d` means "delete all lines not matching foo"
(ie. Vim treats this as a valid bang command).
- `:v!foo!d` is an error, because there is no `:v!` command
(ie. Vim rejects this as an invalid bang command).
- `:s!foo!bar!` means "replace foo with bar"
(ie. Vim does _not_ consider this a bang command, and treats "!" as a
delimiter).
- `:g!!foo!d` means "delete all lines not matching foo"
(ie. Vim treats this as a valid bang command _and_ treats the second
and third "!" as delimiters).
Greg Hurrell [Thu, 2 Dec 2021 21:26:30 +0000 (22:26 +0100)]
refactor: edit some code comments in the name of precision
We're using "slash" in an abstract sense here to mean "delimiter" (in
fact, as I write this, I wonder whether we should just use that word...
🤔), so we shouldn't use a literal "/" in the comments.
Greg Hurrell [Thu, 2 Dec 2021 21:20:53 +0000 (22:20 +0100)]
fix: make `g:LoupeVeryMagic` work with `:su`, `:sub`, `:subs` etc
Previously we were only looking for `:s`, `:g` and `:v`, but we should
actually work for all the non-abbreviated forms too.
Noticed while investigating:
https://github.com/wincent/loupe/issues/20
Seeing as I've blown away my Haskell-based docvim install
on this machine (my personal laptop) while working on the
new-but-not-yet-feature-complete Rust-powered version, I
needed to set up a new install in order to update the docs:
Fixes an annoyance I've long had with `*`, `#` etc; it doesn't respect
'ignorecase' and 'smartcase' settings. It behaves as if 'ignorecase' and
'nosmartcase' were always in effect, unlike `/` and `?`.
In this commit we add a new setting, on by default, that makes all of
the search mappings behave the same, respecting the value of
'ignorecase' and 'smartcase'.
Also as noted in the comments, we take the opportunity to enhance a very
edge-casey thing: that if you have a special char like "\" in your
'iskeyword' setting, then `*` won't work when the cursor is on a `cword`
like "foo\bar". We can fix that with some escaping, seeing as we're
bypassing the whole `*`/`#` mechanism anyway.
Freshened the docs with the following (because my Haskell environment is
horrendously broken on this machine):
Greg Hurrell [Wed, 12 Oct 2016 01:07:02 +0000 (18:07 -0700)]
Add empty .watchmanconfig
Allows a Watchman instance configured with `enforce_root_files` to watch
this directory even if `root_files` does not contain any of the files in
the directory. (Necessary to get around undesired corporate
`/etc/watchman.json` config.)
Folds aren't opening due to some unknown Vim quirk; perhaps there is some
conditional logic in there that prevents the default behavior from happening in
the context of a mapping. Whatever the case, adding an explicit `zv` gives us
the same effect as the default behavior.
Fixes: https://github.com/wincent/loupe/issues/9
Thanks to @adriaanzon for the report and for suggesting the fix.
Greg Hurrell [Sun, 26 Jun 2016 08:25:25 +0000 (01:25 -0700)]
Improve the :noh<space> fix
I had it written like this initially but didn't like it
because of some unwanted space movement behavior which
I couldn't seem to overcome with <Left>, so I tried the
version shipped in the last commit. Turns out this is
better, even if it is not perfect. Moves the cursor to
the right on each run, instead of to the second column.
Still sucks, but it is less jarring.
Greg Hurrell [Sun, 26 Jun 2016 08:01:15 +0000 (01:01 -0700)]
Slightly improve behavior of ":noh<space>"
If you hit ":noh<CR>" you get ideal behavior.
If you hit ":noh<Space>" before this commit, you got nothing until you hit space
again.
With this commit, ":noh<Space>" behaves like ":noh<CR>" (triggers side-effect).
This still isn't ideal, but it is better than it was before.
Warts:
- This is a hack: all we really want is the ability to run a callback when the
real `:noh` is called.
- Hitting <Space> and have it trigger a side-effect is a smell.
- We still get undesired cursor movement: <CR> moves to the start of the current
line in the buffer, and then we get a one-char bump the right, even if I
attempt compensatory cursor movements.
Greg Hurrell [Sat, 25 Jun 2016 05:57:16 +0000 (22:57 -0700)]
Suppress unwanted cursor movement on `:noh<cr>`
I noticed that given:
:cabbrev foo echo "foo"
That `:foo<space>` would produce `:echo "foo" ` (note the trailing space) but
`:foo<cr>` would not, and nor would it trigger any unwanted cursor movement in
the current buffer.
With this change, we get that same behaviour: `:noh<space>` will act a bit
weird, but who uses that? At least `:noh<CR>` does the right thing.
- It means `loupe#private#clear_highlight()` gets called twice.
- It inserts an unwanted `<CR>` due to this behavior noted in the help (`:h
abbreviations`):
> The non-keyword character which ends the abbreviation is inserted
> after the expanded abbreviation.
ie. the cursor moves whenever I hit `<leader>n`. Ugh.
Fix that by using `<bar>` and avoiding the expansion of the abbreviation.
Joe Lencioni [Wed, 23 Sep 2015 17:33:26 +0000 (10:33 -0700)]
Avoid E802
Similar to 156f62c3, we are not entirely sure why this might happen, but
the cost of guarding against it is low. `:h E802` and `:h E803` bring up
the same section, so the root cause is likely similar or the same.
I decided to use a more verbose regex than necessary to make it easier
to search for this line in the code.
The `loupe-history` tag appears twice in the file, which can cause:
> E154: Duplicate tag "loupe-history" in file
Rename the `loupe-history` tag in the OVERRIDES section to
`loupe-history-override` to resolve the clash, and change the other
tags in the section to follow the same `*-override` pattern for
consistency.