From 70d781796591a1eb0892b595a38eb27722460155 Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Wed, 27 May 2020 22:31:12 +0200 Subject: [PATCH] example: automatically read vimrc if it exists --- example/editor.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/example/editor.cpp b/example/editor.cpp index b3a8cd1..6876e75 100644 --- a/example/editor.cpp +++ b/example/editor.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #define EDITOR(editor, call) \ if (QPlainTextEdit *ed = qobject_cast(editor)) { \ @@ -475,6 +476,17 @@ void initHandler(FakeVimHandler *handler) handler->handleCommand(_("set autoindent")); handler->handleCommand(_("set smartindent")); + QString vimrc = QStandardPaths::writableLocation(QStandardPaths::HomeLocation) +#ifdef Q_OS_WIN + + "/_vimrc"; +#else + + "/.vimrc"; +#endif + + if (QFile::exists(vimrc)) { + handler->handleCommand("source " + vimrc); + } + handler->installEventFilter(); handler->setupWidget(); }