From 7bd6124420c30a326b146d019d2be20fabe5fc34 Mon Sep 17 00:00:00 2001 From: amin roosta Date: Tue, 30 Aug 2016 00:29:11 +0430 Subject: [PATCH] implement useSystemClipboard command --- README.md | 8 ++++++++ package.json | 5 +++++ src/configuration/configuration.ts | 1 + src/mode/modeHandler.ts | 9 ++++++--- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 16644a4add8..67d7a37d1b1 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,14 @@ Put the following in your `settings.json`: and restart VSCode. +#### How can I enable yanking to system clipboard by default? + +Put the following in your `settings.json`: + +``` "vim.useSystemClipboard": true``` + +and restart VSCode. + #### Vim option override sequence. The way we load Vim options is slightly different from native Vim as there is some overlap between Code and Vim. The option loading sequence is as below. diff --git a/package.json b/package.json index 2358a407ad2..f4dcc5d125d 100644 --- a/package.json +++ b/package.json @@ -164,6 +164,11 @@ "type": "boolean", "description": "Enable some vim ctrl key commands that override otherwise common operations, like ctrl+c" }, + "vim.useSystemClipboard": { + "type": "boolean", + "description": "Use system clipboard for unnamed register.", + "default": false + }, "vim.insertModeKeyBindings": { "type": "array", "description": "Keybinding overrides to use for insert mode." diff --git a/src/configuration/configuration.ts b/src/configuration/configuration.ts index beaf830ed61..84faf6c93d1 100644 --- a/src/configuration/configuration.ts +++ b/src/configuration/configuration.ts @@ -50,6 +50,7 @@ export class Configuration { } useSolidBlockCursor: boolean = false; + useSystemClipboard: boolean = false; useCtrlKeys: boolean = false; scroll: number = 20; hlsearch: boolean = false; diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts index 49b83eb49d7..838cc01a120 100644 --- a/src/mode/modeHandler.ts +++ b/src/mode/modeHandler.ts @@ -138,8 +138,6 @@ export class VimState { return VisualBlockMode.getBottomRightPosition(this.cursorStartPosition, this.cursorPosition); } - public registerName = '"'; - /** * This is for oddball commands that don't manipulate text in any way. */ @@ -346,6 +344,11 @@ export class ReplaceState { * * delete operator */ export class RecordedState { + + constructor() { + const useClipboard = Configuration.getInstance().useSystemClipboard; + this.registerName = useClipboard ? '*' : '"'; + } /** * Keeps track of keys pressed for the next action. Comes in handy when parsing * multiple length movements, e.g. gg. @@ -389,7 +392,7 @@ export class RecordedState { /** * The register name for this action. */ - public registerName: string = '"'; + public registerName: string; public clone(): RecordedState { const res = new RecordedState();