0

I add the following lines in my .vimrc

let g:shell = "powershell"
cabbrev bter bo terminal g:shell

but that won't work (I got a CreateProcess failed error). I have fixed with

exe "cabbrev bter bo terminal ". g:shell
exe "cabbrev vter vert botright terminal ". g:shell

Are there are any hidden drawbacks with my solutions?

3
  • Good question. By default I used to have set shell="C:\\\\link\\\\to\\\\Anaconda\\\\powershell.exe but then Vim became extremely slow. Therefore, I preferred Vim to "internally" use cmd.exe and open a Powershell terminal through a shortcut inside of Vim. This to avoid leaving Vim windows to do powershell operations in another window for Vim unrelated actions.
    – Barzi2001
    Dec 3, 2022 at 12:24
  • FWIW, there is no " in :help :set commands. set shell="C:… is invalid. It should be set shell=C:….
    – romainl
    Dec 3, 2022 at 12:32
  • Sorry, I mispelled it. The " should not be there.
    – Barzi2001
    Dec 3, 2022 at 12:36

1 Answer 1

1

If you don't pass it a specific command to run, :help :terminal falls back to :help 'shell'. Therefore, you can do:

set shell=powershell

once and for all, which lets you keep your abbreviations simple:

cabbrev bter botright terminal
cabbrev vter vertical botright terminal

If you don't want to set Vim's default shell to powershell, then you can keep using :help :execute.

You might want to switch your concatenation operator to the generally preferred .. but that is far from necessary in this case. Other than that, the approach seems fine to me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.