|
@@ -24,6 +24,8 @@
|
|
|
#include "vsnippetlist.h"
|
|
|
#include "vlivepreviewhelper.h"
|
|
|
#include "vmathjaxinplacepreviewhelper.h"
|
|
|
+#include "vdirectory.h"
|
|
|
+#include "vdirectorytree.h"
|
|
|
|
|
|
extern VMainWindow *g_mainWin;
|
|
|
|
|
@@ -1457,6 +1459,30 @@ bool VMdTab::executeVimCommandInWebView(const QString &p_cmd)
|
|
|
} else if (p_cmd == "nohlsearch" || p_cmd == "noh") {
|
|
|
// :nohlsearch, clear highlight search.
|
|
|
m_webViewer->findText("");
|
|
|
+ } else if (p_cmd == "e") {
|
|
|
+ // :e, enter edit mode.
|
|
|
+ showFileEditMode();
|
|
|
+ } else if (p_cmd.size() > 2 && p_cmd.left(2) == "e ") {
|
|
|
+ // :e <file>, open a note in edit mode.
|
|
|
+ auto filePath = p_cmd.mid(2).trimmed();
|
|
|
+
|
|
|
+ if(filePath.left(2) == "~/") {
|
|
|
+ filePath.remove(0, 1).insert(0, QDir::homePath());
|
|
|
+ } else if(filePath.left(2) == "./" || filePath[0] != '/') {
|
|
|
+ VDirectory *dir = g_mainWin->getDirectoryTree()->currentDirectory();
|
|
|
+ if(filePath.left(2) == "./") {
|
|
|
+ filePath.remove(0, 1);
|
|
|
+ } else {
|
|
|
+ filePath.insert(0, '/');
|
|
|
+ }
|
|
|
+ filePath.insert(0, dir->fetchPath());
|
|
|
+ }
|
|
|
+
|
|
|
+ if(g_mainWin->openFiles(QStringList(filePath), false, OpenFileMode::Edit).size()) {
|
|
|
+ msg = tr("Open %1 in edit mode.").arg(filePath);
|
|
|
+ } else {
|
|
|
+ msg = tr("Unable to open %1").arg(filePath);
|
|
|
+ }
|
|
|
} else {
|
|
|
validCommand = false;
|
|
|
}
|