From 4ad79e4d92ae53e76556b2152bd0f06598cd85a8 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Thu, 7 Sep 2017 20:35:41 +0800 Subject: [PATCH] vim-mode: w to save note --- src/resources/docs/shortcuts_en.md | 3 ++- src/resources/docs/shortcuts_zh.md | 3 ++- src/utils/vvim.cpp | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/resources/docs/shortcuts_en.md b/src/resources/docs/shortcuts_en.md index c2d6c5eb..c0d0557c 100644 --- a/src/resources/docs/shortcuts_en.md +++ b/src/resources/docs/shortcuts_en.md @@ -162,7 +162,7 @@ VNote supports a simple but useful Vim mode, including **Normal**, **Insert**, * 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`, 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 `$`; - Marks `a-z`; - Registers `"`, `_`, `+`, `a-z`(`A-Z`); @@ -170,6 +170,7 @@ VNote supports following features of Vim: - Leader key (`Space`) - Currently `y/d/p` equals to `"+y/d/p`, which will access the system's clipboard; - `` to clear search highlight; + - `w` to save note; - `zz`, `zb`, `zt`; - `u` and `Ctrl+R` for undo and redo; - Text objects `i/a`: word, WORD, `''`, `""`, `` ` ` ``, `()`, `[]`, `<>`, and `{}`; diff --git a/src/resources/docs/shortcuts_zh.md b/src/resources/docs/shortcuts_zh.md index 0fea1434..4fd11406 100644 --- a/src/resources/docs/shortcuts_zh.md +++ b/src/resources/docs/shortcuts_zh.md @@ -163,7 +163,7 @@ VNote支持一个简单但有用的Vim模式,包括 **正常**, **插入** VNote支持以下几个Vim的特性: - `r`, `s`, `S`, `i`, `I`, `a`, `A`, `c`, `C`, `o`, `O`; -- 操作 `d`, `c`, `y`, `p`, `<`, `>`, `gu`, `gU`, `~`; +- 操作 `d`, `c`, `y`, `p`, `<`, `>`, `gu`, `gU`, `J`, `gJ`, `~`; - 移动 `h/j/k/l`, `gj/gk`, `Ctrl+U`, `Ctrl+D`, `gg`, `G`, `0`, `^`, `{`, `}`, `$`; - 标记 `a-z`; - 寄存器 `"`, `_`, `+`, `a-z`(`A-Z`); @@ -171,6 +171,7 @@ VNote支持以下几个Vim的特性: - 前导键 (`Space`) - 目前 `y/d/p` 等同于 `"+y/d/p`, 从而可以访问系统剪切板; - `` 清除查找高亮; + - `w` 保存笔记; - `zz`, `zb`, `zt`; - `u` 和 `Ctrl+R` 撤销和重做; - 文本对象 `i/a`:word, WORD, `''`, `""`, `` ` ` ``, `()`, `[]`, `<>`, `{}`; diff --git a/src/utils/vvim.cpp b/src/utils/vvim.cpp index b56a5423..e60b9480 100644 --- a/src/utils/vvim.cpp +++ b/src/utils/vvim.cpp @@ -5459,6 +5459,10 @@ bool VVim::processLeaderSequence(const Key &p_key) } else if (p_key == Key(Qt::Key_Space)) { // , clear search highlight clearSearchHighlight(); + } else if (p_key == Key(Qt::Key_W)) { + // w, save note + emit m_editor->saveNote(); + message(tr("Note has been saved")); } else { validSequence = false; }