How To Use Vim In Windows Terminal And Powershell Core🔗🔗

The aim of this page📝 is to show how to use the Vim editor to quickly read a file from within a terminal — because opening a workspace within Visual Studio Code is way too slow for volume-heavy spaces.

Please note that for the moment, I only need to read, highlight, copy-paste, and exit. I tried using Nano (5 MB package as opposed to 50 MB of Vim) but it did not work reliably in Windows Terminal (it kept freezing on my machine).

DEMO

1. INSTALL🔗🔗

choco install vim

2. CONFIG🔗🔗

  • locate the installation folder, my chocolatey installation put Vim into c:\tools folder
  • open _vimrc file in the folder where chocolatey installed it
  • append the following to the file
set clipboard=unnamed
set mouse=a
~/.vim
~/.vim/.undo
~/.vim/.backup
~/.vim/.swp

… by running

"~/.vim", "~/.vim/.undo", "~/.vim/.backup", "~/.vim/.swp" | % {mkdir $_}
  • second, add the following lines to _vimrc
set undodir=~/.vim/.undo//
set backupdir=~/.vim/.backup//
set directory=~/.vim/.swp//

3. USE🔗🔗

  • in the terminal, find a find with ctrl+t using PSFzf
  • prefix that with vim
  • navigate with arrows that you need
  • to highlight characters press vy to copy them to system clipboard
  • to highlight lines press Vy to copy
  • or just use the mouse to highlight → y to copy
  • y stands for yank (this is vim parlance)
  • hit :qa! to exit without saving

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store