The Pompitous of Love
The Pompitous of Love

Reputation: 95

Can I use vim-like commands in the WIndows Command line in Windows 10?

Because I use vim (and obviously like it) while working in the command line, I often go through a few keystrokes before I realize I'm not in vim anymore. That's not a huge problem, but when entering a lot of commands on one line, vim-like navigation would really speed things up on the extremely rare occasion cough I make a typo. It would be great it there were a way to make command line typing act at least a little like vim (e.g. Normal mode, Insert mode, movement from the home keys, etc.)

I am open to using a different shell, but would prefer something I can use without learning a ton of new commands (e.g. command line or BASH like). I have else compiled many of my frequent command sequences into .bat files, which I would prefer not to have to change too much to get to work properly.

Upvotes: 2

Views: 5110

Answers (3)

Eric Smith
Eric Smith

Reputation: 5392

I'm surprised nobody has mentioned Clink. It works with cmd.exe, and has support for Vim (well, technically, Vi) key mappings. Sadly, the documentation seems unfinished (to say the least); that said, I have found it to be quite stable, and have used it for a few years now. Doing a quick search yields information on how to set the default editing mode to Vi (versus Emacs).

In short Control+Alt+J switches to Vi mode (assuming one is currently in the default Emacs mode), and a standard Readline inputrc in the right place (my file path is %HOMEPATH%\AppData\Local\clink\clink_inputrc), with the right directive (set editing-mode vi) ensures that a new cmd.exe invocation starts off in Vi mode.

Upvotes: 2

Jonathan.Brink
Jonathan.Brink

Reputation: 25423

When using Windows, a good option would be to install Git, which gives you "Git Bash", which is their distribution of mingw.

Now that you have bash, you can use set -o vi which puts your readline in Vim mode.

https://sanctum.geek.nz/arabesque/vi-mode-in-bash/

Upvotes: 2

builder-7000
builder-7000

Reputation: 7627

I am open to using a different shell, but would prefer something I can use without learning a ton of new commands (e.g. command line or BASH like)

In bash you can enter vi-mode with the command:

set -o vi

This will make shell-editing very similar to Vim-editing. For a cheat-sheet of vim-mode commands see: https://github.com/pkrumins/bash-vi-editing-mode-cheat-sheet/blob/master/bash-vi-editing-mode-cheat-sheet.txt

Upvotes: 1

Related Questions