Skip to content

Commit

Permalink
implement useSystemClipboard command (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
aminroosta authored and johnfn committed Aug 30, 2016
1 parent 05c7e67 commit 214619d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
1 change: 1 addition & 0 deletions src/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class Configuration {
}

useSolidBlockCursor: boolean = false;
useSystemClipboard: boolean = false;
useCtrlKeys: boolean = false;
scroll: number = 20;
hlsearch: boolean = false;
Expand Down
9 changes: 6 additions & 3 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 214619d

Please sign in to comment.