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.
|
Insert fenced code block. Press `Ctrl+M` again to exit. Current selected text will be wrapped into a code block if exists.
|
||||||
- `Ctrl+L`
|
- `Ctrl+L`
|
||||||
Insert link.
|
Insert link.
|
||||||
|
- `Ctrl+'`
|
||||||
|
Insert image.
|
||||||
- `Ctrl+H`
|
- `Ctrl+H`
|
||||||
Backspace. Delete a character backward.
|
Backspace. Delete a character backward.
|
||||||
- `Ctrl+W`
|
- `Ctrl+W`
|
||||||
@ -239,7 +241,7 @@ VNote supports following features of Vim:
|
|||||||
|
|
||||||
- `r`, `s`, `S`, `i`, `I`, `a`, `A`, `c`, `C`, `o`, and `O`;
|
- `r`, `s`, `S`, `i`, `I`, `a`, `A`, `c`, `C`, `o`, and `O`;
|
||||||
- Actions `d`, `c`, `y`, `p`, `<`, `>`, `gu`, `gU`, `J`, `gJ`, and `~`;
|
- 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`;
|
- Marks `a-z`;
|
||||||
- Registers `"`, `_`, `+`, `a-z`(`A-Z`);
|
- Registers `"`, `_`, `+`, `a-z`(`A-Z`);
|
||||||
- Jump locations list (`Ctrl+O` and `Ctrl+I`);
|
- Jump locations list (`Ctrl+O` and `Ctrl+I`);
|
||||||
|
@ -64,6 +64,8 @@
|
|||||||
插入代码块;再次按`Ctrl+M`退出。如果已经选择文本,则将当前选择文本嵌入到代码块中。
|
插入代码块;再次按`Ctrl+M`退出。如果已经选择文本,则将当前选择文本嵌入到代码块中。
|
||||||
- `Ctrl+L`
|
- `Ctrl+L`
|
||||||
插入链接。
|
插入链接。
|
||||||
|
- `Ctrl+'`
|
||||||
|
插入图片。
|
||||||
- `Ctrl+H`
|
- `Ctrl+H`
|
||||||
退格键,向前删除一个字符。
|
退格键,向前删除一个字符。
|
||||||
- `Ctrl+W`
|
- `Ctrl+W`
|
||||||
@ -240,7 +242,7 @@ VNote支持以下几个Vim的特性:
|
|||||||
|
|
||||||
- `r`, `s`, `S`, `i`, `I`, `a`, `A`, `c`, `C`, `o`, `O`;
|
- `r`, `s`, `S`, `i`, `I`, `a`, `A`, `c`, `C`, `o`, `O`;
|
||||||
- 操作 `d`, `c`, `y`, `p`, `<`, `>`, `gu`, `gU`, `J`, `gJ`, `~`;
|
- 操作 `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`(`A-Z`);
|
- 寄存器 `"`, `_`, `+`, `a-z`(`A-Z`);
|
||||||
- 跳转位置列表 (`Ctrl+O` and `Ctrl+I`);
|
- 跳转位置列表 (`Ctrl+O` and `Ctrl+I`);
|
||||||
|
@ -647,20 +647,21 @@ bool VVim::handleKeyPressEvent(int key, int modifiers, int *p_autoIndentPos)
|
|||||||
{
|
{
|
||||||
if (modifiers == Qt::NoModifier
|
if (modifiers == Qt::NoModifier
|
||||||
|| modifiers == Qt::KeypadModifier) {
|
|| 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.
|
// Repeat.
|
||||||
V_ASSERT(m_keys.last().isDigit());
|
|
||||||
|
|
||||||
m_keys.append(keyInfo);
|
m_keys.append(keyInfo);
|
||||||
resetPositionInBlock = false;
|
resetPositionInBlock = false;
|
||||||
goto accept;
|
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;
|
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:
|
case Movement::EndOfLine:
|
||||||
{
|
{
|
||||||
// End of line (block).
|
// End of line (block).
|
||||||
|
@ -396,6 +396,7 @@ private:
|
|||||||
PageDown,
|
PageDown,
|
||||||
HalfPageUp,
|
HalfPageUp,
|
||||||
HalfPageDown,
|
HalfPageDown,
|
||||||
|
StartOfVisualLine,
|
||||||
StartOfLine,
|
StartOfLine,
|
||||||
EndOfLine,
|
EndOfLine,
|
||||||
FirstCharacter,
|
FirstCharacter,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user