Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there an editor which has the option to "split the screen" into two or more parts, accessing more than one file (possibly with a file tree) without opening more editor windows at once, and how would one do this (what are the commands).

I don't know if I made myself clear, but "split screen" is the only way to describe what I want to achieve. I want to use it to program, having more than one file open for editing. Note that I'm pretty new to both vi and emacs, if these are capable of doing this. Also, if this has to be done through a terminal editor, can it be done in the same terminal, regardless of the screen size?

share|improve this question
1  
I know you asked specifically about editors and not terminals, but I think it is worth to note for future visitors: the terminal emulator terminator also has the feature of split screen: ctrl + shift + e will split vertically and ctrl + shift + o will split horizontally (and also ctrl + shift + t will open a new tab) –  Carlos Campderrós Aug 2 '12 at 14:55
    
@CarlosCampderrós I'll keep that in mind, thanks! –  Eve Aug 2 '12 at 16:41
1  
@CarlosCampderrós: You can also use a multiplexer like screen or tmux to achieve that in other terminal emulators. Disadvantage, of course, is that you have to remember to run them first, but the flexibility is probably worth it. –  Phoshi Aug 3 '12 at 0:19

10 Answers 10

up vote 32 down vote accepted

vim can easily do that:

ctrl+ws - Split windows

ctrl+ww - switch between windows

ctrl+wq - Quit a window

ctrl+wv - Split windows vertically

:sp filename

will open filename in new buffer and split a window.

share|improve this answer
4  
Or type :help CTRL-W to see all the split window operations. –  Bernhard Aug 2 '12 at 6:22
    
Wow, great! I also stumbled upon ":split", but it only splits horizontally. Can you please just include which version of vim this is? Thanks! –  Eve Aug 2 '12 at 16:43
    
@Eve I use VIM (Vi IMproved) 7.3. –  rush Aug 2 '12 at 19:00
    
I would create a mapping like map <C-left> <C-W><left> for each of the directions to ease switching windows. I use a mapping lie that except with the hjkl keys for movement but if you do pick vim it might be some time before you're ready to use those. –  Matt Aug 3 '12 at 1:41
1  
@Eve - you can also use :vsplit to create a vertical split, and as with :split it accepts a filename or command –  Useless Aug 3 '12 at 10:43

This can be done using Emacs. It works in GUI and in terminal mode. You can even split multiple times. Here are some basic key combinations:

C-x 2 Split the selected window into two windows, one above the other (split-window-below).
C-x 3 Split the selected window into two windows, positioned side by side (split-window-right).
C-Mouse-2 In the mode line of a window, split that window.

Source: http://www.gnu.org/software/emacs/manual/html_node/emacs/Split-Window.html

share|improve this answer
1  
For anyone unfamiliar with Emacs terminology, it is worth noting that an Emacs window is what many other editors call a screen or a panel. An Emacs frame is what others call a window (it is called a frame because the windows within it are framed either by the desktop decoration (title-bar and borders) or by the terminal... Windows contain buffers (some text; usually a file). –  Peter.O Aug 2 '12 at 3:34
1  
@Peter.O - Not just for those unfamiliar with Emacs... I have been using Emacs for over 5 years and would not have been able to explain the differences. I just use it. –  jordanm Aug 2 '12 at 3:37

With vim, you can use split or vsplit.

The first one will split horizintally and the second one will split vertically.

CTRLw then to navigate through split screens.

You can also use tab. tabnew filename will open filename in a new tab. You can use tabnext and :tabprevious to navigate between tabs.

I personnaly maps the left and right arrows to navigate between tabs:

map <right> :tabnext<CR>
map <left> :tabprevious<CR>
inoremap <right> <ESC>:tabnext<CR>a
inoremap <left> <ESC>:tabprevious<CR>a
share|improve this answer
1  
Additionally, the NERD_tree plug-in can be use for showing the directory tree in a separate split. (vim.org/scripts/script.php?script_id=1658) –  Bernhard Aug 2 '12 at 5:51

joe (Joe's Own Editor) can do this, too:

ctrl+ko - split window horizontally

ctrl+kp - switch to the previous window

ctrl+kn - switch to the next window

ctrl+ke - open new file in current window

ctrl+kg - grow height of current window

ctrl+kt - shrink height of current window

ctrl+ki - hide all windows except the current one, press again to show all windows again

ctrl+c or ctrl+kx - close a window

share|improve this answer

Kate

KDE Advanced Text Editor is very featureful.
It has everything you described in the question and much more.

See for yourself:

Screenshot

To split the view, go to ViewSplit View. Then you can select one of these options:

  • Split Vertical (Ctrl+Shift+L)
  • Split Horizotal (Ctrl+Shift+T)
  • Close Current View (Ctrl+Shift+R)

To get the layout like on this screenshot, Split Vertical, click on the bottom view and then Split Horizontal.

Of course, the boundaries of the views can be changed by dragging the borders (splitters) between them. To switch between the views, use F8 and Shift+F8.

By the way, Kate has a so-called VI Mode (SettingsConfigure Kate…Editing → VI Input Mode). Then the shortcuts for view splitting become the same as in Vim (see this answer).

share|improve this answer

Regarding file trees, I personally use NERDtree with Vim. It requires Pathogen. I found the command to open the tree (:NERDtree toggle, iirc) to be a bit long, so I remapped it to <F2>. If you're working on a project with lots of files in lots of directories (think Rails projects), it's a really nice.

EDIT:

NERDtree is on Github: https://github.com/scrooloose/nerdtree

This is the remapping I use in my .vimrc: map <F2> :NERDTreeToggle<CR>

share|improve this answer
    
Thanks, I may have other questions about this. Those I reserve for another time. ;) –  Eve Aug 4 '12 at 2:31

Sublime Text 2 can do that (and many more).

share|improve this answer
    
Very nice, thanks! –  Eve Aug 4 '12 at 2:30

GEdit has some plugins to split screen.

share|improve this answer
3  
Could you at least mention what they are? –  Michael Mrozek Aug 3 '12 at 13:45

If you are interested in getting to grips a bit better with VIM, check out vimcasts.org, it has a bunch of really friendly video tutorials. This one especially for split screen magic

Enjoy!

share|improve this answer
    
That's nice, thanks so much! I would up this more, but I'm only allowed one. –  Eve Aug 4 '12 at 2:23

I use tmux and vim for split-screen editing in a terminal-based environment, though you could use any command-line based text editor for this (e.g. nano, emacs etc.).

tmux is short for "terminal multiplexer" and it allows you to create sessions with multiple terminals, running in separate "windows" and also "panes" within these windows, which are what allow you to split the screen. tmux is included in the repositories of many Linux and BSD distributions. I find this to be the most flexible option for coding, as I can also add splits and windows that contain terminals where I can compile code and use a version control system, like git alongside my code editing.

Here is an example of how I would create a split screen editing session using tmux and vim.

First open a terminal. In the below commands written after $ are issued from the command line. This uses the default key-bindings in tmux.

  1. Start a new tmux session. Here we make one called "coding":

    $ tmux new -s coding

    tmux just opened

  2. Press Ctrl+b followed by either % for a vertical split or " for a horizontal split.

    vertical split

    horizontal split

  3. You can move between the splits (or in tmux parlance, the "panes") by pressing Ctrl+b followed by o.

  4. Now open up a text editor with whatever files you want to edit in each pane. Here I have just opened two text files using vim, e.g.

    $ vim file1.txt

    Switch panes:Ctrl+b followed by o.

    $ vim file2.txt

    editing two files simultaneously

tmux is extremely advanced, allowing for multiple panes in a single window arranged in various ways and vim allows you to open multiple text files at once in tabs. I tend to use both the tabbing in vim and the panes in tmux to allow me to edit, version control and debug code simultaneously. If you have time to invest in learning the keyboard shortcuts and features of tmux it can be a very powerful development environment.

A tmux cheat sheet for starting out: dayid's screen and tmux cheat sheet

A tutorial on tabs in vim: Vim tips: Using tabs

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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