---
title: 'Use GVim under WSL2'
---
Use GVim under WSL2
===
[](https://hackmd.io/FuUDnZg5RVSzEwGiL5jjdg)
Bash script
---
```gherkin=
#!/bin/bash
# CS: [27-Sep-2024 11:03] Put this script in ~/bin
RED=$(tput setaf 1)
PURPLE=$(tput setaf 125)
GREEN=$(tput setaf 2)
RESET=$(tput sgr0)
#location of gvim
GVIM='/mnt/c/Program Files/Vim/vim91/gvim.exe'
FILE=`realpath "${1:-.}"`
#
# need to convert /mnt/c/xxx --> C:\xxx
#
[[ $FILE == /mnt/c/* ]] && FILE=${FILE/\/mnt\/c\//C:\\}
[[ $FILE == /mnt/d/* ]] && FILE=${FILE/\/mnt\/d\//D:\\}
echo "Launch ${GREEN}gvim.exe [windows version]${RESET} for file: "$FILE
`"$GVIM" $FILE` &
```
Here I am using the Windows version of GVim. Plguins that rely on external commands such as Shellcheck do not work properly.
> I choose a lazy person to do a hard job. Because a lazy person will find an easy way to do it. [name=Bill Gates]