mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-06 06:19:52 +08:00
vim-mode: support g0 (start of visual line)
This commit is contained in:
parent
70eb04ebd2
commit
2c1e8e33fe
@ -64,6 +64,8 @@ Insert inline code. Press `Ctrl+K` again to exit. Current selected text will be
|
||||
Insert fenced code block. Press `Ctrl+M` again to exit. Current selected text will be wrapped into a code block if exists.
|
||||
- `Ctrl+L`
|
||||
Insert link.
|
||||
- `Ctrl+'`
|
||||
Insert image.
|
||||
- `Ctrl+H`
|
||||
Backspace. Delete a character backward.
|
||||
- `Ctrl+W`
|
||||
@ -239,7 +241,7 @@ VNote supports following features of Vim:
|
||||
|
||||
- `r`, `s`, `S`, `i`, `I`, `a`, `A`, `c`, `C`, `o`, and `O`;
|
||||
- Actions `d`, `c`, `y`, `p`, `<`, `>`, `gu`, `gU`, `J`, `gJ`, and `~`;
|
||||
- Movements `h/j/k/l`, `gj/gk`, `Ctrl+U`, `Ctrl+D`, `gg`, `G`, `0`, `^`, `{`, `}`, and `$`;
|
||||
- Movements `h/j/k/l`, `gj/gk/g0`, `Ctrl+U`, `Ctrl+D`, `gg`, `G`, `0`, `^`, `{`, `}`, and `$`;
|
||||
- Marks `a-z`;
|
||||
- Registers `"`, `_`, `+`, `a-z`(`A-Z`);
|
||||
- Jump locations list (`Ctrl+O` and `Ctrl+I`);
|
||||
|
@ -64,6 +64,8 @@
|
||||
插入代码块;再次按`Ctrl+M`退出。如果已经选择文本,则将当前选择文本嵌入到代码块中。
|
||||
- `Ctrl+L`
|
||||
插入链接。
|
||||
- `Ctrl+'`
|
||||
插入图片。
|
||||
- `Ctrl+H`
|
||||
退格键,向前删除一个字符。
|
||||
- `Ctrl+W`
|
||||
@ -240,7 +242,7 @@ VNote支持以下几个Vim的特性:
|
||||
|
||||
- `r`, `s`, `S`, `i`, `I`, `a`, `A`, `c`, `C`, `o`, `O`;
|
||||
- 操作 `d`, `c`, `y`, `p`, `<`, `>`, `gu`, `gU`, `J`, `gJ`, `~`;
|
||||
- 移动 `h/j/k/l`, `gj/gk`, `Ctrl+U`, `Ctrl+D`, `gg`, `G`, `0`, `^`, `{`, `}`, `$`;
|
||||
- 移动 `h/j/k/l`, `gj/gk/g0`, `Ctrl+U`, `Ctrl+D`, `gg`, `G`, `0`, `^`, `{`, `}`, `$`;
|
||||
- 标记 `a-z`;
|
||||
- 寄存器 `"`, `_`, `+`, `a-z`(`A-Z`);
|
||||
- 跳转位置列表 (`Ctrl+O` and `Ctrl+I`);
|
||||
|
@ -647,20 +647,21 @@ bool VVim::handleKeyPressEvent(int key, int modifiers, int *p_autoIndentPos)
|
||||
{
|
||||
if (modifiers == Qt::NoModifier
|
||||
|| modifiers == Qt::KeypadModifier) {
|
||||
if (!m_keys.isEmpty()) {
|
||||
if (checkPendingKey(Key(Qt::Key_G))) {
|
||||
// StartOfVisualLine.
|
||||
tryAddMoveAction();
|
||||
m_tokens.append(Token(Movement::StartOfVisualLine));
|
||||
processCommand(m_tokens);
|
||||
} else if (m_keys.isEmpty()) {
|
||||
// StartOfLine.
|
||||
tryAddMoveAction();
|
||||
m_tokens.append(Token(Movement::StartOfLine));
|
||||
processCommand(m_tokens);
|
||||
} else if (m_keys.last().isDigit()) {
|
||||
// Repeat.
|
||||
V_ASSERT(m_keys.last().isDigit());
|
||||
|
||||
m_keys.append(keyInfo);
|
||||
resetPositionInBlock = false;
|
||||
goto accept;
|
||||
} else {
|
||||
// StartOfLine.
|
||||
tryAddMoveAction();
|
||||
|
||||
m_tokens.append(Token(Movement::StartOfLine));
|
||||
|
||||
processCommand(m_tokens);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2694,6 +2695,17 @@ bool VVim::processMovement(QTextCursor &p_cursor,
|
||||
break;
|
||||
}
|
||||
|
||||
case Movement::StartOfVisualLine:
|
||||
{
|
||||
// Start of the visual line.
|
||||
if (!p_cursor.atBlockStart()) {
|
||||
p_cursor.movePosition(QTextCursor::StartOfLine, p_moveMode, 1);
|
||||
hasMoved = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Movement::EndOfLine:
|
||||
{
|
||||
// End of line (block).
|
||||
|
@ -396,6 +396,7 @@ private:
|
||||
PageDown,
|
||||
HalfPageUp,
|
||||
HalfPageDown,
|
||||
StartOfVisualLine,
|
||||
StartOfLine,
|
||||
EndOfLine,
|
||||
FirstCharacter,
|
||||
|
Loading…
x
Reference in New Issue
Block a user