├── .gitignore ├── README.md ├── main.ts ├── manifest.json ├── package.json ├── rollup.config.js ├── tsconfig.json └── versions.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Intellij 2 | *.iml 3 | .idea 4 | 5 | # npm 6 | node_modules 7 | package-lock.json 8 | 9 | # build 10 | main.js 11 | *.js.map 12 | 13 | # obsidian 14 | data.json 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Obsidian Toggleable Vim Mode [![GitHub tag (latest by date)](https://img.shields.io/github/v/tag/phibr0/obsidian-toggleable-vim)](https://github.com/phibr0/obsidian-dictionary/releases) ![GitHub all releases](https://img.shields.io/github/downloads/phibr0/obsidian-toggleable-vim/total) [![](https://img.shields.io/badge/Support%3F-Buy%20me%20a%20Coffee-yellow)](https://www.buymeacoffee.com/phibr0) 2 | 3 | This Plugin adds a Hotkey to toggle Obsidian's integrated Vim Emulation on or off. 4 | 5 | ## Usage 6 | 7 | After activating the Plugin you will find a new Command (*Toggle Vim Mode*), which you can either set a Hotkey to or use it from the Command Palette (default: `ctrl` + `p`) 8 | 9 | ## Support me 10 | 11 | If you find this Plugin helpful, consider supporting me: 12 | 13 | 14 | -------------------------------------------------------------------------------- /main.ts: -------------------------------------------------------------------------------- 1 | import { MarkdownView, Plugin, WorkspaceLeaf } from 'obsidian'; 2 | 3 | export default class ToggleVimPlugin extends Plugin { 4 | 5 | async onload() { 6 | this.addCommand({ 7 | id: 'toggle-vim-mode', 8 | name: 'Toggle Vim Mode', 9 | callback: () => { 10 | //@ts-ignore 11 | this.app.vault.setConfig("vimMode", !this.app.vault.getConfig("vimMode")); 12 | this.app.workspace.iterateAllLeaves((i) => { 13 | if (i.view instanceof MarkdownView) { 14 | //@ts-ignore 15 | i.view.editor.cm.setOption("keyMap", this.app.vault.getConfig("vimMode") ? "vim" : "default"); 16 | //@ts-ignore 17 | i.view.editor.cm.refresh(); 18 | console.log("toggled vim"); 19 | } 20 | }); 21 | } 22 | }); 23 | } 24 | 25 | onunload() { 26 | console.log('unloading plugin'); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "obsidian-toggle-vim", 3 | "name": "Toggleable Vim Mode", 4 | "version": "1.1.0", 5 | "minAppVersion": "0.12.3", 6 | "description": "This Plugins provides a Hotkey to toggle Obsidian's Vim Mode Emulation.", 7 | "author": "phibr0", 8 | "authorUrl": "https://github.com/phibr0", 9 | "isDesktopOnly": true 10 | } 11 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "obsidian-sample-plugin", 3 | "version": "0.12.0", 4 | "description": "This is a sample plugin for Obsidian (https://obsidian.md)", 5 | "main": "main.js", 6 | "scripts": { 7 | "dev": "rollup --config rollup.config.js -w", 8 | "build": "rollup --config rollup.config.js --environment BUILD:production" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "MIT", 13 | "devDependencies": { 14 | "@rollup/plugin-commonjs": "^18.0.0", 15 | "@rollup/plugin-node-resolve": "^11.2.1", 16 | "@rollup/plugin-typescript": "^8.2.1", 17 | "@types/node": "^14.14.37", 18 | "obsidian": "^0.12.0", 19 | "rollup": "^2.32.1", 20 | "tslib": "^2.2.0", 21 | "typescript": "^4.2.4" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import typescript from '@rollup/plugin-typescript'; 2 | import {nodeResolve} from '@rollup/plugin-node-resolve'; 3 | import commonjs from '@rollup/plugin-commonjs'; 4 | 5 | const isProd = (process.env.BUILD === 'production'); 6 | 7 | const banner = 8 | `/* 9 | THIS IS A GENERATED/BUNDLED FILE BY ROLLUP 10 | if you want to view the source visit the plugins github repository 11 | */ 12 | `; 13 | 14 | export default { 15 | input: 'main.ts', 16 | output: { 17 | dir: '.', 18 | sourcemap: 'inline', 19 | sourcemapExcludeSources: isProd, 20 | format: 'cjs', 21 | exports: 'default', 22 | banner, 23 | }, 24 | external: ['obsidian'], 25 | plugins: [ 26 | typescript(), 27 | nodeResolve({browser: true}), 28 | commonjs(), 29 | ] 30 | }; -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "inlineSourceMap": true, 5 | "inlineSources": true, 6 | "module": "ESNext", 7 | "target": "es6", 8 | "allowJs": true, 9 | "noImplicitAny": true, 10 | "moduleResolution": "node", 11 | "importHelpers": true, 12 | "lib": [ 13 | "dom", 14 | "es5", 15 | "scripthost", 16 | "es2015" 17 | ] 18 | }, 19 | "include": [ 20 | "**/*.ts" 21 | ] 22 | } 23 | -------------------------------------------------------------------------------- /versions.json: -------------------------------------------------------------------------------- 1 | { 2 | "1.1.0": "0.12.3", 3 | "1.0.1": "0.12.3", 4 | "1.0.0": "0.12.3" 5 | } 6 | --------------------------------------------------------------------------------