From 657be0aa3e3308ac33d2bac745ac9bfab4b9ef18 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Sun, 8 Sep 2024 08:50:35 -0600 Subject: [PATCH] vim doc tweaks (#17564) Release Notes: - N/A --- docs/src/vim.md | 25 ++++++++++++++++--------- typos.toml | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/docs/src/vim.md b/docs/src/vim.md index 089602916b..8656cfc7ba 100644 --- a/docs/src/vim.md +++ b/docs/src/vim.md @@ -96,8 +96,6 @@ Finally, vim mode's search and replace functionality is backed by Zed's. This me You can edit your personal key bindings with `:keymap`. For vim-specific shortcuts, you may find the following template a good place to start. -> **Note:** We made some breaking changes in Zed version `0.145.0`. For older versions, see [the previous version of this document](https://github.com/zed-industries/zed/blob/c67aeaa9c58619a58708722ac7d7a78c75c29336/docs/src/vim.md#L90). - ```json [ { @@ -106,6 +104,12 @@ For vim-specific shortcuts, you may find the following template a good place to // put key-bindings here if you want them to work in normal & visual mode } }, + { + "context": "vim_mode == normal && !menu", + "bindings": { + // "shift-y": ["workspace::SendKeystrokes", "y $"] // use nvim's Y behavior + } + }, { "context": "vim_mode == insert", "bindings": { @@ -162,7 +166,7 @@ Vim mode allows you to enable Zed’s command palette with `:`. This means that Additionally vim mode contains a number of aliases for popular vim commands to ensure that muscle memory works. For example `:w` will save the file. -We do not (yet) emulate the full power of vim’s command line, in particular we special case specific patterns instead of using vim's range selection syntax, and we do not support arguments to commands yet. Please reach out on [GitHub](https://github.com/zed-industries/zed) as you find things that are missing from the command palette. +We do not (yet) emulate the full power of vim’s command line, in particular we we do not support arguments to commands yet. Please reach out on [GitHub](https://github.com/zed-industries/zed) as you find things that are missing from the command palette. As mentioned above, one thing to be aware of is that the regex engine is slightly different from vim's in `:%s/a/b`. @@ -191,6 +195,12 @@ Currently supported vim-specific commands: :cc, :ll to open the errors page +# handling git diff +:dif[fupdate] + to view the diff under the cursor ("d o" in normal mode) +:rev[ert] + to revert the diff under the cursor ("d p" in normal mode) + # jump to position : to jump to a line number @@ -200,11 +210,8 @@ Currently supported vim-specific commands: to jump to next/prev line matching foo # replacement (/g is always assumed and Zed uses different regex syntax to vim) -:%s/foo/bar/ +:[range]s/foo/bar/ to replace instances of foo with bar -:X,Ys/foo/bar/ - to limit replacement between line X and Y - other ranges are not yet implemented # editing :j[oin] @@ -213,18 +220,18 @@ Currently supported vim-specific commands: to delete the current line (no range is yet supported) :s[ort] [i] to sort the current selection (with i, case-insensitively) +:y[ank] ``` As any Zed command is available, you may find that it's helpful to remember mnemonics that run the correct command. For example: ``` -:diff Toggle Hunk [Diff] :diffs Toggle all Hunk [Diffs] -:revert Revert Selected Hunks :cpp [C]o[p]y [P]ath to file :crp [C]opy [r]elative [P]ath :reveal [Reveal] in finder :zlog Open [Z]ed Log +:clank [C]ancel [lan]guage server work[k] ``` ## Settings diff --git a/typos.toml b/typos.toml index ad18f890e5..2bbb4907a7 100644 --- a/typos.toml +++ b/typos.toml @@ -46,6 +46,7 @@ extend-exclude = [ [default] extend-ignore-re = [ 'cl\[ist]', + '\[lan\]guage', '"ba"', ":ba\\|z", # :/ crates/collab/migrations/20231009181554_add_release_channel_to_rooms.sql