Skip to content

Commit

Permalink
example: automatically read vimrc if it exists
Browse files Browse the repository at this point in the history
  • Loading branch information
sandsmark committed May 27, 2020
1 parent dcfc14a commit 70d7817
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions example/editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <QTextEdit>
#include <QTextStream>
#include <QTemporaryFile>
#include <QStandardPaths>

#define EDITOR(editor, call) \
if (QPlainTextEdit *ed = qobject_cast<QPlainTextEdit *>(editor)) { \
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 70d7817

Please sign in to comment.