Commit Graph

118 Commits

Author SHA1 Message Date
cf68e01510 vim:keys: Center line when opening quickfix entry 2025-06-27 16:37:20 +02:00
f5c6baf856 vim:keys: Add note about macro_type augroup 2025-06-27 16:36:21 +02:00
a8d46caa78 vim:keys: Modularize changes to ]]/][ mappings
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")
2025-06-27 16:33:56 +02:00
2d9b00a0d3 vim:keys: Convert decimal numbers with <leader>hex 2025-06-27 13:29:25 +02:00
781e3a2f4b vim:keys: Substitute only inside visual selection
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`).
2025-06-26 16:18:22 +02:00
6b98838f7e vim:keys: Remove unneeded mappings
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`)
2025-06-02 20:59:43 +02:00
f0ec75aa9c vim:keys: Map <leader>d also in visual mode 2025-06-02 20:59:43 +02:00
533e82cb81 vim:keys: Add :keeppatterns to substituting vmaps
All of these should not modify @/.
2025-06-02 20:59:43 +02:00
e0e1e5d971 vim:keys: Fix <Cmd> vmaps
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.
2025-06-02 20:59:37 +02:00
9dc8e71ce6 vim:keys: Map <C-w>! to move window to new tab
I memorized tmux's <prefix>! mapping, but always forget how it is done
in vim.
2025-05-28 14:05:40 +02:00
bf4c5a1291 vim:keys: Alias <leader>g* to <leader>* 2025-03-25 18:03:59 +01:00
cbacf728e6 vim:keys: Add e flag to [[ and ]] mappings
Let the search place the cursor on the curly brace instead of the start
of the line.
2024-11-20 12:55:19 +01:00
611e83b1c8 vim:keys: Streamline [[ and ]] mappings
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.
2024-11-20 12:55:18 +01:00
f5ec488b08 vim:keys: Better >> & << for tab-indent-space-align 2024-11-16 02:27:22 +01:00
626855ec69 vim:keys:TODO: Add <leader>[hl] v-mappings
TODO: <SUBJECT>
2024-10-21 17:19:52 +02:00
f9764de6d5 vim:keys:TODO: Handle errors when referencing commits 2024-10-18 16:13:36 +02:00
908cc494a2 vim:keys: Fix typo in comment 2024-10-16 14:53:39 +02:00
4cc3b6536c vim:keys: Keep cursor position on visual yank
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
2024-09-25 14:33:00 +02:00
b8f5d63b4c vim:keys: Fix triggering of hlsearch on n/N 2024-09-25 14:32:59 +02:00
459e0b7113 vim:keys:TODO: Modularize changes to ]]/][ maps 2024-09-25 14:32:59 +02:00
6f8fc406d6 vim:keys: Fix [[ mappings
I broke the default behaviour of jumping to open braces that are alone
on their line.
2024-09-25 10:54:57 +02:00
9d756c2748 zsh:alias: Add duration that formats seconds 2024-09-20 16:29:51 +02:00
61f1a7ee9b vim:keys: Cycle spelllangs only between en & de
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`.
2024-09-18 15:16:42 +02:00
e54b1fc71a vim:keys: WIP fix swapping of ]] and ][
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.
2024-08-30 18:14:20 +02:00
034db637c7 vim:keys: Relax [[ maps for different style guides
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.
2024-08-30 18:14:20 +02:00
6260c84f3a vim:aucmd: Clear highlights on exiting visual mode
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").
2024-03-24 16:56:11 +01:00
a4405ee614 vim:keys: Change family of <C-w>gf mappings
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]`")
2024-03-18 14:39:03 +01:00
8096917ad4 vim:keys: Open file in split with <C-w>g[fF]
Open the file under the cursor in a split window similar to the rest of
the `<C-w>` mappings. I'm surprised this mapping does not exist by
default.
2024-03-07 13:09:41 +01:00
b3f1a469db vim:keys: Clear highlights on normal-mode Esc
Clear highlights from visual selection or word highlighting together
with the highlight of the search results.
2024-02-20 01:21:46 +01:00
58243e0510 *: Update and add TODOs 2024-01-05 16:20:42 +01:00
35536bfa7b vim:keys: VMap <leader>\_ to escape underscores 2023-07-16 13:13:44 +02:00
4e79b369c3 vim:keys: Rewrite mapping functions to use dicts
Instead of having a long list of `map` commands, define a dictionary for
the mappings and take shortcuts were possible.
2023-07-16 13:11:14 +02:00
80e09685e7 vim:keys: Add macro_type for uppercase snakecase 2023-06-27 18:23:02 +02:00
b64e5fef4d vim:keys: Add <leader>g* analog to <leader>*
Do the same thing without the word boundaries.
2023-05-22 15:14:13 +02:00
7065f4b043 keys:vim: Fix display of search count on n & N
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
2023-05-21 16:01:37 +02:00
848df05810 vim:keys: Fix <Tab>/<C-I> confused mapping
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.
2023-05-12 12:06:46 +02:00
5f20d6d26f vim:keys: Respect 'foldopen' on remapped movements
Execute 'zv' depending on the existence of the equivalent movement type
in 'foldopen'.
2023-05-12 12:05:20 +02:00
f18cc6f05a vim:keys: Open folds on remapped movement commands
See 'foldopen':

> NOTE: When the command is part of a mapping this option is not used.
> Add the |zv| command to the mapping to get the same effect.
2023-05-12 12:04:43 +02:00
7462b5a7af vim:keys: Remove <C-U> uses behind <Cmd>
<C-U> is not needed when using <Cmd> for visual mappings.

Fix: fc9874bf97 ("vim:keys: Use <Cmd> for plain command mappings")
2023-03-22 13:19:41 +01:00
3066eed1c7 vim:keys:TODO: Fix search results center mappings 2023-02-27 14:09:32 +01:00
3fac79115f vim:keys: Fix &spell toggle mapping
I don't if something changed or if this was broken from the get to, but
now it is fixed.
2023-02-27 11:02:47 +01:00
fc9874bf97 vim:keys: Use <Cmd> for plain command mappings
<Cmd> executes the command directly in the current mode without changing
to command-line mode and triggering Cmdline{Enter,Leave}.
2023-02-27 10:59:41 +01:00
a4c6e4ebfd vim:keys: Center hunk after moving with gitgutter 2023-02-23 14:47:59 +01:00
44194bd09c vim:keys: Expand visual selection on <leader>[jk]
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.
2023-02-15 16:44:17 +01:00
b7dcc1f79c vim:keys: Map real <C-BS> to delete one word
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/
2023-02-15 14:30:52 +01:00
a05d99df95 vim:keys: Add <leader>v/ as vmap too
Just escape visual mode and reuse the existing normal-mode mapping.
2023-02-15 14:28:35 +01:00
1d58eb729d vim:keys: Add <leader>* vmap to ripgrep selection
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.
2023-02-15 14:26:05 +01:00
1933218756 vim:keys: Center search results after N too
Forgot that one.
2023-02-15 11:37:07 +01:00
8e71a3f12e vim:keys:vmap *: Center search results
Center search results by further evaluating mappings in {rhs}.
2023-02-15 11:37:00 +01:00
9f3b9ac79a vim:keys: Save unnamed reg when getting selection
Fix that the mappings modified the unnamed register.
2023-02-15 11:35:50 +01:00