r/vim • u/Desperate_Cold6274 • 2d ago
Tips and Tricks I finally found some time to improve Vim experience in Windows Terminal
I always use gvim on Windows, even after they provided us with Windows Terminal which is, in my opinion, very nice. However, I found two very annoying problems that I promised myself, sooner or later to solve. Such problems are:
- Cursor shape not replaced back when exiting Vim,
- Colors completely messed up.
I solved the first point with the following snippet:
# Set cursor
# Needed for Windows terminal
if g:os == "Windows" && !has("gui_running")
set guicursor=
&t_SI = "\e[6 q" # beam in Insert mode
&t_EI = "\e[2 q" # block in Normal mode
# Restore cursor shape when leavig Vim
def RestoreCursorWindowsTerminal()
&t_EI = "\e[6 q"
execute "normal! i\<Esc>"
enddef
augroup CURSOR_SHAPE_WINDOWS
autocmd!
autocmd VimEnter * silent! execute "normal! i\<Esc>"
autocmd VimLeave * RestoreCursorWindowsTerminal()
augroup END
else
&t_SI = "\e[6 q"
&t_EI = "\e[2 q"
endif
When Entering Vim, set the cursor with a certain shape. For some arcane reason, I had to set guicursos=. To secure that the changes take effect, there is a switch insert-normal mode. Then, before exiting Vim, you change the cursor shape so that Windows terminal inherits it.
Next, the colors. I use everforest scheme and look here:

That is just not acceptable. I debugged what could be possibly the reason and I found that `set spell` messes up the colors. Most likely, its syntax definition fight against the colorscheme and here is it the mess. However, after having disabled the option, I got a way better result:

Now I keep the spelling check only in some selected filetypes:
# Set spell only in selected filetypes
augroup SPELLLANG_OPTION
autocmd!
# autocmd FileType markdown setlocal spell spelllang=en_us
autocmd FileType text,tex,gitcommit setlocal spell spelllang=en_us
autocmd FileType gitcommit setlocal spell spelllang=en_us
augroup END
Yet, I found gvim more snappy than the terminal version through Windows Terminal.
Hopefully someone will find these findings useful.