Skip to content

Commit

Permalink
Merge pull request #430 from rebornix/ScrollHalf
Browse files Browse the repository at this point in the history
Ctrl+U and Ctrl+D
  • Loading branch information
johnfn authored Jul 12, 2016
2 parents c2ff2fb + 2571b7d commit 0246008
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -367,10 +367,10 @@ Status | Command | Description
Status | Command | Description
---|--------|------------------------------
:x: | :1234: CTRL-E | window N lines downwards (default: 1)
:x: | :1234: CTRL-D | window N lines Downwards (default: 1/2 window)
:warning: | :1234: CTRL-D | window N lines Downwards (default: 1/2 window)
:x: | :1234: CTRL-F | window N pages Forwards (downwards)
:x: | :1234: CTRL-Y | window N lines upwards (default: 1)
:x: | :1234: CTRL-U | window N lines Upwards (default: 1/2 window)
:warning: | :1234: CTRL-U | window N lines Upwards (default: 1/2 window)
:x: | :1234: CTRL-B | window N pages Backwards (upwards)
:x: | z CR or zt | redraw, current line at top of window
:warning: | z. or zz | redraw, current line at center of window
Expand Down
2 changes: 1 addition & 1 deletion extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function activate(context: vscode.ExtensionContext) {
showCmdLine("", modeHandlerToFilename[activeFileName()]);
});

'rfb'.split('').forEach(key => {
'rfbdu'.split('').forEach(key => {
registerCommand(context, `extension.vim_ctrl+${key}`, () => handleKeyEvent(`ctrl+${key}`));
});

Expand Down
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@
"command": "extension.vim_ctrl+b",
"when": "editorTextFocus"
},
{
"key": "ctrl+u",
"command": "extension.vim_ctrl+u",
"when": "editorTextFocus"
},
{
"key": "ctrl+d",
"command": "extension.vim_ctrl+d",
"when": "editorTextFocus"
},
{
"key": "ctrl+w",
"command": "extension.vim_switchWindow",
Expand Down Expand Up @@ -109,14 +119,18 @@
"vim.insertModeKeyBindings": {
"type": "array",
"description": "Keybinding overrides to use for insert mode."
},
},
"vim.useSolidBlockCursor": {
"type": "boolean",
"description": "Use a non blinking block cursor."
},
"vim.visualModeKeyBindings": {
"type": "object",
"description": "Keybinding overrides to use for visual mode."
},
"vim.scroll": {
"type": "number",
"description": "Number of lines to scroll with CTRL-U and CTRL-D commands."
}
}
}
Expand Down
20 changes: 20 additions & 0 deletions src/actions/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,26 @@ class CommandMoveFullPageUp extends BaseCommand {
}
}

@RegisterAction
class MCommandMoveHalfPageDown extends BaseMovement {
modes = [ModeName.Normal];
keys = ["ctrl+d"];

public async execAction(position: Position, vimState: VimState): Promise<Position> {
return new Position(Math.min(TextEditor.getLineCount() - 1, position.line + vimState.settings.scroll), position.character);
}
}

@RegisterAction
class MCommandMoveHalfPageUp extends BaseMovement {
modes = [ModeName.Normal];
keys = ["ctrl+u"];

public async execAction(position: Position, vimState: VimState): Promise<Position> {
return new Position(Math.max(0, position.line - vimState.settings.scroll), position.character);
}
}

@RegisterAction
class CommandDeleteToLineEnd extends BaseCommand {
modes = [ModeName.Normal];
Expand Down
2 changes: 2 additions & 0 deletions src/mode/modeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export class VimState {

export class VimSettings {
useSolidBlockCursor = false;
scroll = 20;
}

export class SearchState {
Expand Down Expand Up @@ -477,6 +478,7 @@ export class ModeHandler implements vscode.Disposable {
private loadSettings(): void {
this._vimState.settings.useSolidBlockCursor = vscode.workspace.getConfiguration("vim")
.get("useSolidBlockCursor", false);
this._vimState.settings.scroll = vscode.workspace.getConfiguration("vim").get("scroll", 20) || 20;
}

/**
Expand Down

0 comments on commit 0246008

Please sign in to comment.