Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement useSystemClipboard command #665

Merged
merged 1 commit into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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