Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I open files within vim's terminal emulator

Tags:

vim

Using vim, I use :term to open the terminal emulator. After cd /path/to/project within the terminal emulator, I have a file called foo.txt. If I did vim foo.txt to open it as I would in a normal terminal, it would open vim within vim which causes a variety of issues. I see two potential solutions:

  • Find some way to open a file in a split from the terminal emulator
  • Find some way to change the cwd of vim to the cwd of the terminal emulator.

Does anyone have tips on either solution?

like image 206
Kutub Gandhi Avatar asked Oct 26 '25 15:10

Kutub Gandhi


2 Answers

Inside Vim's builtin terminal, do

vim --remote foo.txt

This assume that your Vim was compiled with the +clientserver option. You can check with :version or :echo has('clientserver').

like image 192
gdupras Avatar answered Oct 29 '25 07:10

gdupras


vim --remote works on vim, but neovim compiles without clientserver. neovim-remote seems to be an alternative for neovim.

like image 21
Kutub Gandhi Avatar answered Oct 29 '25 08:10

Kutub Gandhi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!