Instead of changing the functionality of `]]` and swapping `][` and
`]]` in one mapping, do it in two separate steps. This way both changes
can be used independently of each other.
Fixes: 459e0b7113 ("vim:keys:TODO: Modularize changes to ]]/][ maps")
When substituting in a visual block selection, the automatically
inserted range `'<,'>` is not enough as the pattern will also match
outside of the selection on the same lines. To only match inside the
selection, insert the `\%V` atom.
Theoretically the pattern will also need the atom before the last
character to make sure that everything is inside the selection, but this
can be inserted manually when needed (see `:h /\%V`).
These were commented out already for longer. For `(` I have delimitMate
and the `<CR>` mapping conflicts with the one from coc.nvim (which
includes the `<C-G>u`)
When switching to <Cmd> for mappings in fc9874bf97 ("vim:keys: Use
<Cmd> for plain command mappings") I forgot that the previously inserted
selection range marks (i.e. '<,'>) are missing now. This broke vmaps
that used :substitute without having added them manually.
Since <Cmd> has some performance benefits, I want to keep it and add the
missing marks where needed.
Use the `s` flag, so that the position before the last jump is updated
automatically.
Use `<Cmd>` so that both normal and visual mode mappings become
identical and can be merged. This has the added benefit that it now also
maps in operator-pending mode.
Complete the TODOs.
The cursor is always moved to the beginning of the selection when
yanking in visual mode. This mapping resets the position back to where
it was.
Link: https://stackoverflow.com/a/3806664/20927629
If :h 'spelllang' is something else, do nothing.
A possible future improvement could be to keep a list of the languages
to cycle between and first adding any other languages to this list so
that one could return to the original setting. I see this especially
useful when the current setting is `en,de`.
Make ][ and ]] work like they used to with the new functionality through
a workaround.
The problem is that recursive mappings are evaluated at runtime not
"compiletime" - which is what I would need in this situation.
I still want both mappings blocks so that they are not entangled and I
can turn each one off without affecting the other.
I use the [[ & etc. mappings to jump between function definitions in C.
This works as long as the braces are put on a newline (like in the
kernel coding style guide).
Relax the mappings for opening braces to jump to unindented lines with
an opening brace to cover also different style guides.
When exiting visual mode I want to clear the highlights of the visual
selection. As this is done automatically now, <Esc> does not need to do
it (and i had problems with keys.vim executing ClearHighlights because
of the script variables).
This reverts commit b3f1a469db ("vim:keys: Clear highlights on
normal-mode Esc").
The mapping to split and open the file under cursor exists by default
(not as I thought), but is not <C-w>gf but rather <C-w>f.
Swap the mappings for tab and split 'destination'.
Fixes: 8096917ad ("vim:keys: Open file in split with `<C-w>g[fF]`")
When 'lazyredraw' is set the search count is not displayed. This seems
like a bug as it is being displayed if `n` and `N` are not remapped.
Fix this by shortly turning off lazyredraw and resetting it after.
This leads to the new problem that hlsearch is not triggered. It does
stay though after searching with `/<CR>`, so this is a smaller issue I
can fix later.
Found thanks to: https://github.com/kevinhwang91/nvim-hlslens/issues/34
In a terminal with libtermkey support (e.g. my st build), <Tab> and
<C-I> can be differentiated.
Because of that the keys have to be mapped explicitly.
Add two vmaps that call ExpandVisualSelection() for the appropriate
direction.
That expands the selection over all directly following lines in the
given direction that contain the current selection at the same position.
Example:
```
- TODO: ...
- TODO: ...
- TODO: ...
```
In visual block one can select `TODO: ` on the first line and then call
`ExpandVisualSelection(1)` which results in a block selection that spans
over all other TODOs as well.
Map <C-BS> (i.e. Ctrl-Backspace) to delete one word in insert mode & co.
as it is properly recognized in some terminals implementing [fixterm][1]
(e.g. kitty and patched st).
Keep the <C-H> mapping for other terminals but reuse the <C-BS> mapping.
[1]: http://www.leonerd.org.uk/hacks/fixterms/
Similar to <leader>* in normal mode, set the search pattern to the
visual selection and start a ripgrep search.
To not mess up the commandline, potential quotes that are the same as
the ones used around the string need to be escaped. As this is only
possible with double quotes, a second layer of backslash escaping is
needed as well.
Because of that, **before** escaping backslashes and double quotes, all
backslashes need to be escaped a second time. The other way around would
result in two backslashes in front of each double quote, which would
miss the whole point entirely.
In addition GetVisualSelection needed to be expanded to first reselect
the visual selection for it to work in the new mapping.