Skip to content

Add --vim flag to emulate vim editing mode - #111218

Merged
alexey-milovidov merged 73 commits into
ClickHouse:masterfrom
spinojara:vim
Nov 13, 2026
Merged

alexey-milovidov merged 73 commits into
ClickHouse:masterfrom
spinojara:vim

Conversation

@spinojara

@spinojara spinojara commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

This PR depends on ClickHouse/replxx#43.
It also depends on ClickHouse/replxx#49 and ClickHouse/replxx#52 (bind_default_key, to take a non-ASCII argument of f, t and r).

Changelog category (leave one):

  • New Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Added the client flag --vim which emulates vim editing mode for the client.


Workflow [PR]
Sync PR [sync-upstream/pr/111218]

Version info

  • Merged into: 26.11.1.2185-master (included in 26.11 and later)

@CLAassistant

CLAassistant commented Jul 21, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ alexey-milovidov
❌ spinojara
You have signed the CLA already but the status is still pending? Let us recheck it.

@spinojara

Copy link
Copy Markdown
Contributor Author

I have signed a CCLA.

@spinojara spinojara changed the title Vim Add --vim flag to emulate vim editing mode Jul 21, 2026
@thevar1able thevar1able added the can be tested Allows running workflows for external contributors label Jul 21, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6d1b5bd]

Summary: ✅


AI Review

Summary

The PR adds optional --vim editing to the interactive client, including motions, operators, text objects, documentation, and terminal regression tests. Reviewed head 6d1b5bd65f46b9299463a11f147b5b5bc8d16682 and all prior discussion; no remaining actionable findings. An isolated terminal harness using the unchanged VimMode.cpp and pinned replxx matched clean Vim in 61 focused comparisons, including the latest multiline bracket fixes. The fetched CI report contains no failed tests; a full ClickHouse build was not run locally.

Final Verdict

Status: ✅ Approve.

@clickhouse-gh clickhouse-gh Bot added pr-feature Pull request with new product feature submodule changed At least one submodule changed in this PR. manual approve Manual approve required to run CI labels Jul 21, 2026
@clickhouse-gh clickhouse-gh Bot added the comp-cli clickhouse-client (interactive CLI) and client library. label Sep 4, 2026
@alexey-milovidov

Copy link
Copy Markdown
Member

Thanks! I've merged the submodule PR.

@alexey-milovidov alexey-milovidov self-assigned this Oct 12, 2026

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code LGTM.

What is more correct to say?

  • VI mode;
  • VIM mode;

@alexey-milovidov

Copy link
Copy Markdown
Member

If saying vi is more correct, let's rename it...

@spinojara

spinojara commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor Author

If saying vi is more correct, let's rename it...

There are many vim specific keybindings, so it should be called vim mode I think. I will rebase on master.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=111218&sha=cdcf76648ac6a81df5b056b396a8dbfa9d6ea22c&name_0=PR&name_1=Storage%20memory%20check and provide a fix in a separate PR. This PR only changes the interactive client (--vim), so it cannot affect server storage memory. A fix may already be in progress: #128485

@groeneai

groeneai commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

The fix is #128485 (mine, open, CI green). This PR is not involved.

Cause: 02_insert_data.sql inserts created = now() - INTERVAL number SECOND (100000 rows = 27.8 h) into a table partitioned by toYYYYMM(created), and the job runs in Europe/Amsterdam. For the first 27.8 h of every month the data spans two partitions, so the later scenarios compress two parts concurrently, and how much pooled ZSTD workspace is still live at a checkpoint becomes a scheduling draw.

This job ran at 2026-11-01 13:06 UTC, inside this month's window (2026-10-31 23:00 to 2026-11-02 02:46 UTC), and the report's cross-diff is exactly that:

  • 03: +28,672 B ZSTD_resetCCtx_internal > ZSTD_cwksp_create and +6,152 B CompressionCodecZSTD::doCompressData (of +34,824 B)
  • 05: +40,960 / -28,672 B in the same ZSTD_cwksp_create stack (net +12,288 of +12,120 B)
  • 09: the sum of the two

6 PRs, this one included, went red this way inside the window. #128485 pins the inserted timestamps to a fixed date, so the table always has one partition. Since the window closed, the 02 master baseline is back at ~26 KB on every run, so the next run here should pass even without it.

@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Thanks, @groeneai. The Storage memory check failure is tracked by #128485 and is unrelated to this client-only change.

Status at eee5530: the branch includes master from 2026-11-02 and merges cleanly. The three open AI review threads (counted iw across a line break, exclusive w/W ending in the first column, cursor after a linewise delete) are addressed in eee5530, with regressions in 05394_client_vim_mode.expect. They are waiting for re-review. CI has not run on this commit yet because of the manual approve label. The remaining CHANGES_REQUESTED review is a maintainer hold on the final merge decision.

Comment thread src/Client/VimMode.cpp Resolved
Comment thread src/Client/VimMode.cpp Resolved
Comment thread src/Client/VimMode.cpp Resolved
alexey-milovidov pushed a commit to ianton-ru/ClickHouse that referenced this pull request Nov 3, 2026
… max_upload_part_size

The Azure object storage generator drew `strict_upload_part_size` (0..100 MiB,
plus a rare 2**64 - 1) and `min_upload_part_size` (rare 2**64 - 1) independently
of `max_upload_part_size` (floor 16 MiB). `RequestSettings::validateUploadSettings`
rejects strict > max and max < min, so the disk's startup `checkAccess` throws
INVALID_SETTING_VALUE, the server exits, and `dolor.py` only reports a startup
timeout. Seen in La Casa Del Dolor (amd_msan) on PR ClickHouse#111218: strict 87.22 MiB
against max 16 MiB.

Bound both under the lower bound of `max_upload_part_size` (16 MiB, bits=24),
as the S3 block already does for `s3_min_upload_part_size`. Driving the real
`add_single_disk`, about 4.2% of generated Azure disks were rejected before and
none after (150k disks, 1M direct draws).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov and others added 2 commits November 4, 2026 00:32
… the line break of an empty line ending a counted `iw`, `ce` on an empty last line, `v` forcing for linewise motions in the vim mode

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Addressed the four open AI review threads in b096515: counted iw ending on an empty line, canceling counted iw / aw when there are too few chunks, ce / cE on an empty last line, and v forcing for linewise motions (dvj, dvG, ...). Each one has a regression in 05394_client_vim_mode.expect, which passes locally. I also merged master (26e5685).

The only CI failure was La Casa Del Dolor (amd_msan). Its randomized config set azure_strict_upload_part_size above azure_max_upload_part_size, so the server failed to start. That is unrelated to this PR, and the fix is #128857, which is now merged and included through the master merge.

Comment thread src/Client/VimMode.cpp Resolved
alexey-milovidov and others added 2 commits November 5, 2026 02:55
…, `dvd`/`cvc`, `dvl` at the end of a line in the vim mode

- A linewise motion forced characterwise by `v` that ends in the first column of a line now ends
  at the end of the previous line (or becomes linewise when it starts in the indentation), like
  vim, so `gg$dvG` keeps the line break.
- `v` now applies to the doubled operators: `dvd` and `cvc` act characterwise exclusive up to the
  first non-blank of the last line of the count instead of on whole lines.
- `dvl` does not go past the last character of the line: when the count stops short, the motion
  is inclusive and `v` makes it exclusive, so `dvl` on the last character deletes nothing and
  never consumes the line break.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment thread src/Client/VimMode.cpp Resolved
Comment thread src/Client/VimMode.cpp Resolved
Comment thread src/Client/VimMode.cpp Resolved
Comment thread src/Client/VimMode.cpp Resolved
…ext objects, `g` prefix after `dvgg`, counted `dd`/`cc`/`S` on the last line in the vim mode

- Whitespace that starts within a line ends at the end of that line in counted `iw`/`aw`, so e.g. `d2iw` on `note  ` keeps the line break instead of joining the next line into a comment.
- A counted `aw` skips the line break at the end of a non-empty line like `iw`, keeps trailing whitespace within the line, and takes the leading whitespace when the selection does not end with whitespace.
- `v` after the operator makes the text objects (`iw`, `aw`, `i(`, ...) exclusive, and `w` that stops at the end of a line or of the input is inclusive on its last character, so `dvw` there deletes nothing.
- The second `g` of `gg` leaves the `g` prefix mode on every path, so the command after a forced characterwise `d2vgg` is not swallowed.
- Counted `dd`, `cc` and `S` fail on the last line, like in vim.

All expected results are verified against vim 9 with `-u NONE`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Status at 4470f31: the four AI review findings (counted iw/aw keeping the line break after trailing spaces, v with w and text objects, the g prefix after d2vgg, counted dd/cc/S on the last line) are fixed. Each has a regression in 05394_client_vim_mode.expect, and those threads are now resolved. The branch is one day behind master and merges cleanly, so no merge was needed. CI has not run on this commit yet because of the manual approve label. The remaining CHANGES_REQUESTED review is a maintainer hold on the final merge decision.

Comment thread src/Client/VimMode.cpp Resolved
Comment thread src/Client/VimMode.cpp Resolved
Comment thread src/Client/VimMode.cpp Resolved
alexey-milovidov and others added 3 commits November 6, 2026 12:47
…line inner bracket objects, `cv0` on an empty line, quotes in comments in the vim mode

- `aw` cancels when no word follows the selected whitespace before the end of the input, e.g. `c2aw` on the last word before an empty last line, or `caw` on trailing blanks.
- The inner object of a multiline block starts on the next line when the opening bracket ends its line, and ends before the line break when only blanks precede the closing bracket, so `ci(` keeps the brackets on their own lines (and is linewise when both hold), as in vim.
- `v` makes `0` inclusive only when the cursor is on a character, so `cv0` on an empty line keeps its line break.
- A quote inside a `--`, `#` or `/* */` comment does not start a literal, so an apostrophe in a comment no longer hides the brackets after it from `%` and the bracket objects.

All expected results are verified against vim 9 with `-u NONE`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he timeout of `05394_client_vim_mode` on macOS

- Classify quotes with the comment rules of the `Lexer`: `//` starts a line comment, like `--` and `# `, and block comments nest. An apostrophe in such a comment no longer hides the brackets after it from `%` and the bracket objects.
- The test exceeded the 60 s time limit of the fast test on macOS: every Escape was followed by a pause of 0.3 s. The escape delay of the vim mode is 10 ms (`set_escdelay(10)`), so a pause of 0.1 s is still ten times longer. The test now runs in about 20 s, and three copies in parallel pass in about 30 s.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=111218&sha=8f277594819846b2ee654c7f8f1eb0c16bab0cae&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29
ClickHouse#111218

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…me limit

The single expect test took about 46 seconds in the Linux fast test and
exceeded the 60-second per-test limit of `Fast test (arm_darwin)`:
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=111218&sha=8f277594819846b2ee654c7f8f1eb0c16bab0cae&name_0=PR&name_1=Fast%20test%20%28arm_darwin%29
PR: ClickHouse#111218

The cases are independent (each one submits its own query and none relies on
a find, register or history entry from an earlier case), so they are split in
order between `05394_client_vim_mode_{1,2,3,4}.expect`, each with its own
client session. The cases themselves are unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Status at 332d356: the only failure in the last full CI run (8f27759) was 05394_client_vim_mode hitting the 60 s per-test limit in Fast test (arm_darwin). On Linux it took about 46 s. eee2c5c already shortened the pause after Escape, and 332d356 also splits the test, in order and with the cases unchanged, into 05394_client_vim_mode_{1,2,3,4}.expect, each with its own client session. Locally each part takes about 5 s. There are no unresolved review threads. The branch is three days behind master and has no conflicts. CI is waiting on the manual approve label. The remaining CHANGES_REQUESTED review is a maintainer hold on the final merge decision.

Comment thread src/Client/VimMode.cpp Resolved
Comment thread src/Client/VimMode.cpp Resolved
Comment thread src/Client/VimMode.cpp Resolved
alexey-milovidov and others added 3 commits November 8, 2026 16:22
…ty line, counted `%`, linewise deletes over whole lines in the vim mode

- `v` makes `cw` on an empty line inclusive, so it also changes the first character of the next line, like `cvw` in vim.
- Backspace without an operator stops on an empty previous line instead of skipping it.
- A count before `%` is a percentage of the input: `50%` goes linewise to the first non-blank of the line halfway through, and a count above 100 fails.
- Like `op_delete` in vim, a characterwise delete without `v` over several lines becomes linewise when only blanks precede its start and follow its end. The new shared `vimDeleteLinewise` applies it to `%`, the word motions, and the word and bracket objects, e.g. `d%` and `d4e` over whole lines.
- The new cases are in `05394_client_vim_mode_5.expect`, so that each test stays well within the time limit of the fast test.

All expected results are verified against vim 9 with `-u NONE`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With `v` after the operator, `i(` and `a(` now follow vim's range
computation before toggling the inclusivity: `i(` starts on the next line
when the opening bracket ends its line, and when the closing bracket is in
the first column or after blanks, the object is exclusive up to the start
of the next line, so `v` also takes that character. An exclusive range that
ends in the first column ends at the end of the previous line and may become
linewise, as for other motions. Previously, `v` only decremented the raw
delimiter-to-delimiter count, so `ggjcvi(9000)` on a multiline block left an
extra closing bracket.

The expected results are verified against vim 9.1 (`-u NONE`).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@alexey-milovidov

Copy link
Copy Markdown
Member

🕵 Status at 6d1b5bd: every CI check passed, there are no unresolved review threads, and the branch is two days behind master with no conflicts. The only pending check is license/cla: @spinojara, please sign the Contributor License Agreement at https://cla-assistant.io/ClickHouse/ClickHouse?pullRequest=111218. The remaining CHANGES_REQUESTED review is a maintainer hold on the final merge decision.

@spinojara

Copy link
Copy Markdown
Contributor Author

@alexey-milovidov I have already signed a CCLA.

@alexey-milovidov alexey-milovidov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All ok except the complex logic of the vim mode itself, that couldn't be comprehend. It is well isolated in a single file.

@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 13, 2026
Merged via the queue into ClickHouse:master with commit 14f2227 Nov 13, 2026
187 of 188 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-cli clickhouse-client (interactive CLI) and client library. external Author is not a member of the ClickHouse organization manual approve Manual approve required to run CI pr-feature Pull request with new product feature pr-synced-to-cloud The PR is synced to the cloud repo submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants