diff --git a/src/resources/vnote.ini b/src/resources/vnote.ini index c45b4f8c..4f035cf2 100644 --- a/src/resources/vnote.ini +++ b/src/resources/vnote.ini @@ -162,9 +162,14 @@ backup_directory=. ; String which is appended to a file name to make the name of the backup file backup_extension=.vswp -; Enable back file +; Enable backup file enable_backup_file=true +; Skipped keys in Vim mode +; c: Ctrl+C +; v: Ctrl+V +vim_exemption_keys=cv + [web] ; Location and configuration for Mathjax mathjax_javascript=https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.2/MathJax.js?config=TeX-MML-AM_CHTML diff --git a/src/utils/vvim.cpp b/src/utils/vvim.cpp index a29e9ea7..77c2d8c7 100644 --- a/src/utils/vvim.cpp +++ b/src/utils/vvim.cpp @@ -1367,6 +1367,12 @@ bool VVim::handleKeyPressEvent(int key, int modifiers, int *p_autoIndentPos) expandSelectionToWholeLines(cursor); m_editor->setTextCursorW(cursor); } + } else if (VUtils::isControlModifierForVim(modifiers)) { + if (g_config->getVimExemptionKeys().contains('v')) { + // Let it be handled outside. + resetState(); + goto exit; + } } break; @@ -1642,6 +1648,12 @@ bool VVim::handleKeyPressEvent(int key, int modifiers, int *p_autoIndentPos) } break; + } else if (VUtils::isControlModifierForVim(modifiers)) { + if (g_config->getVimExemptionKeys().contains('c')) { + // Let it be handled outside. + resetState(); + goto exit; + } } break; diff --git a/src/vconfigmanager.cpp b/src/vconfigmanager.cpp index e93bdb8f..d868e6b4 100644 --- a/src/vconfigmanager.cpp +++ b/src/vconfigmanager.cpp @@ -280,6 +280,9 @@ void VConfigManager::initialize() m_enableBackupFile = getConfigFromSettings("global", "enable_backup_file").toBool(); + + m_vimExemptionKeys = getConfigFromSettings("global", + "vim_exemption_keys").toString(); } void VConfigManager::initSettings() diff --git a/src/vconfigmanager.h b/src/vconfigmanager.h index 6a411325..9eb0aff4 100644 --- a/src/vconfigmanager.h +++ b/src/vconfigmanager.h @@ -387,6 +387,8 @@ public: // Get defined external editors. QVector> getExternalEditors() const; + const QString &getVimExemptionKeys() const; + private: // Look up a config from user and default settings. QVariant getConfigFromSettings(const QString §ion, const QString &key) const; @@ -730,6 +732,11 @@ private: // Whether enable backup file. bool m_enableBackupFile; + // Skipped keys in Vim mode. + // c: Ctrl+C + // v: Ctrl+V + QString m_vimExemptionKeys; + // The name of the config file in each directory, obsolete. // Use c_dirConfigFile instead. static const QString c_obsoleteDirConfigFile; @@ -1826,4 +1833,9 @@ inline bool VConfigManager::getEnableBackupFile() const return m_enableBackupFile; } +inline const QString &VConfigManager::getVimExemptionKeys() const +{ + return m_vimExemptionKeys; +} + #endif // VCONFIGMANAGER_H