How To Use Vim In Windows Terminal And Powershell Core๐Ÿ”—๐Ÿ”—

Fast text/markdown grabbing with syntax highlighting๐Ÿ”—

Pavol Kutaj
2 min readMay 6, 2022

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 v โ†’ y to copy them to system clipboard
  • to highlight lines press V โ†’ y 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

--

--

Pavol Kutaj

Today I Learnt | Infrastructure Support Engineer at snowplow.io with a passion for cloud infrastructure/terraform/python/docs. More at https://pavol.kutaj.com