How To Use Vim In Windows Terminal And Powershell Core๐๐
Fast text/markdown grabbing with syntax highlighting๐
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).
1. INSTALL๐๐
choco install vim
- use kelleyma49/PSFzf: A PowerShell wrapper around the fuzzy finder fzf for the lookup of a particular file with a
Ctrl+T
shortcut
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
- 1) this enables system-wide clipboard
- 2) this enables mouse to highlight sections of texts
- vim does not paste to the system clipboard โ some instructions tell you about using its clipboard working within the app itself
- to stop polluting your folder with swap files, first, create the following folders
~/.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