vim: Add (half of) ctrl-v/ctrl-q (#19585)

Release Notes:

- vim: Add `ctrl-v`/`ctrl-q` to type any unicode code point. For example
`ctrl-v escape` inserts an escape character(U+001B), or `ctrl-v u 1 0 E
2` types ტ (U+10E2). As in vim `ctrl-v ctrl-j` inserts U+0000 not
U+000A. Zed does not yet implement insertion of the vim-specific
representation of the typed keystroke for other keystrokes.
- vim: Add `ctrl-shift-v` as an alias for paste on Linux
This commit is contained in:
Conrad Irwin 2024-10-31 23:25:42 -06:00 committed by GitHub
parent f8ab86f930
commit 75f1862268
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 337 additions and 10 deletions

View file

@ -77,6 +77,7 @@ pub enum Operator {
Uppercase,
OppositeCase,
Digraph { first_char: Option<char> },
Literal { prefix: Option<String> },
Register,
RecordRegister,
ReplayRegister,
@ -444,6 +445,7 @@ impl Operator {
Operator::Yank => "y",
Operator::Replace => "r",
Operator::Digraph { .. } => "^K",
Operator::Literal { .. } => "^V",
Operator::FindForward { before: false } => "f",
Operator::FindForward { before: true } => "t",
Operator::FindBackward { after: false } => "F",
@ -467,6 +469,18 @@ impl Operator {
}
}
pub fn status(&self) -> String {
match self {
Operator::Digraph {
first_char: Some(first_char),
} => format!("^K{first_char}"),
Operator::Literal {
prefix: Some(prefix),
} => format!("^V{prefix}"),
_ => self.id().to_string(),
}
}
pub fn is_waiting(&self, mode: Mode) -> bool {
match self {
Operator::AddSurrounds { target } => target.is_some() || mode.is_visual(),
@ -479,6 +493,7 @@ impl Operator {
| Operator::ReplayRegister
| Operator::Replace
| Operator::Digraph { .. }
| Operator::Literal { .. }
| Operator::ChangeSurrounds { target: Some(_) }
| Operator::DeleteSurrounds => true,
Operator::Change