pub struct InsertEscapeSequence { /* private fields */ }Expand description
Configures the character sequence that leaves Insert mode.
Default is jj. A prefix is inserted into the buffer immediately and
remembered only as a possible escape, so a lone j, a mismatch, context
switch, or caller that never supplies another input cannot lose text. When
the complete sequence arrives, its already-inserted prefix is removed and
the buffer follows the same cursor-normalization contract as
EditorInput::Escape.
Use Self::disabled to permit literal jj, or Self::new to replace
the default with another sequence such as jk.
use vim_navigation::InsertEscapeSequence;
assert_eq!(InsertEscapeSequence::default().as_str(), Some("jj"));
assert_eq!(InsertEscapeSequence::new("jk")?.as_str(), Some("jk"));
assert_eq!(InsertEscapeSequence::disabled().as_str(), None);Implementations§
Source§impl InsertEscapeSequence
impl InsertEscapeSequence
Sourcepub fn new(sequence: &str) -> Result<Self, InsertEscapeSequenceError>
pub fn new(sequence: &str) -> Result<Self, InsertEscapeSequenceError>
Creates a non-empty escape sequence containing no line separators.
The sequence is matched as Unicode scalar values in insertion order.
Use Self::disabled instead of an empty string.
§Errors
Returns InsertEscapeSequenceError for an empty sequence or one
containing \n or \r.
Sourcepub const fn disabled() -> Self
pub const fn disabled() -> Self
Disables Insert-mode character escape recognition.
With this setting, jj and every other character sequence are inserted
literally; EditorInput::Escape remains available.