Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a new file in vim in a new window

Tags:

vim

unix

Is there a way to open vim in a new shell window or tab? I'm used to doing $ mate file, which opens the file in a new window.

I prefer having one 'central shell' where I issue commands and edit files in other windows or tabs, as necessary. How do people normally open vim files locally?

like image 722
David542 Avatar asked May 25 '12 19:05

David542


People also ask

How do I open a vim file in a new window?

To do this, click on the Buffers menu at the top and click the dotted line with the scissors. Otherwise you can just open a new tab from your terminal session and launch vi from there.

How do I open multiple windows in Vim?

To split the vim screen horizontally, or open a new workspace at the bottom of the active selection, press Ctrl + w , followed by the letter 's' . In the example below, the left section has been split into two workspaces.

How do I switch between files in vim?

Switch between files Here, N is capital (Type SHIFT+n). Start editing the files as the way you do with Vim editor. Press 'i' to switch to interactive mode and modify the contents as per your liking. Once done, press ESC to go back to normal mode.


2 Answers

from inside vim, use one of the following

open a new window below the current one:

:new filename.ext

open a new window beside the current one:

:vert new filename.ext
like image 74
Massa Avatar answered Oct 25 '22 02:10

Massa


You can do so from within vim, using its own windows or tabs.

One way to go is to utilize the built-in file explorer; activate it via :Explore, or :Texplore for a tabbed interface (which I find most comfortable).

:Texplore (and :Sexplore) will also guard you from accidentally exiting the current buffer (editor) on :q once you're inside the explorer.

To toggle between open tabs, use gt or gT (next tab and previous tab, respectively).

See also Using tab pages on the vim wiki.

like image 16
Eliran Malka Avatar answered Oct 25 '22 03:10

Eliran Malka