Skip to content

Commit

Permalink
vim: add guu gUU g~~ g/ (zed-industries#12789)
Browse files Browse the repository at this point in the history
Release Notes:

- vim: Add `g/` for project search
  • Loading branch information
ConradIrwin authored Jun 7, 2024
1 parent e174f16 commit 75f8be6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
22 changes: 22 additions & 0 deletions assets/keymaps/vim.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"g shift-e": ["vim::PreviousWordEnd", { "ignorePunctuation": true }],

"/": "vim::Search",
"g /": "pane::DeploySearch",
"?": [
"vim::Search",
{
Expand Down Expand Up @@ -433,6 +434,27 @@
"d": "vim::CurrentLine"
}
},
{
"context": "Editor && vim_operator == gu",
"bindings": {
"g u": "vim::CurrentLine",
"u": "vim::CurrentLine"
}
},
{
"context": "Editor && vim_operator == gU",
"bindings": {
"g shift-u": "vim::CurrentLine",
"shift-u": "vim::CurrentLine"
}
},
{
"context": "Editor && vim_operator == g~",
"bindings": {
"g ~": "vim::CurrentLine",
"~": "vim::CurrentLine"
}
},
{
"context": "Editor && vim_mode == normal && vim_operator == d",
"bindings": {
Expand Down
4 changes: 2 additions & 2 deletions crates/gpui/src/keymap/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl KeyBindingContextPredicate {
}
_ if is_identifier_char(next) => {
let len = source
.find(|c: char| !is_identifier_char(c))
.find(|c: char| !is_identifier_char(c) && !is_vim_operator_char(c))
.unwrap_or(source.len());
let (identifier, rest) = source.split_at(len);
source = skip_whitespace(rest);
Expand Down Expand Up @@ -356,7 +356,7 @@ fn is_identifier_char(c: char) -> bool {
}

fn is_vim_operator_char(c: char) -> bool {
c == '>' || c == '<'
c == '>' || c == '<' || c == '~'
}

fn skip_whitespace(source: &str) -> &str {
Expand Down
2 changes: 2 additions & 0 deletions docs/src/vim.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ g < The same, but backwards
g a Add a visual selection for every copy of the current word
# Pane management
g / Open a project-wide search
g <space> Open the current search excerpt
<ctrl-w> <space> Open the current search excerpt in a split
<ctrl-w> g d Go to definition in a split
<ctrl-w> g D Go to type definition in a split
# Insert mode
i a / a a Select the function argument the cursor is in
ctrl-x ctrl-o Open the completion menu
ctrl-x ctrl-c Request GitHub Copilot suggestion (if configured)
ctrl-x ctrl-a Open the inline AI assistant (if configured)
Expand Down

0 comments on commit 75f8be6

Please sign in to comment.