LoginSignup
7
7

More than 5 years have passed since last update.

Vim Working with multiple files

Posted at

vim cheatsheet

# Open all files
vim .

# To open all files in a dir in tabs
$ vim * -p

# To open all files in a dir in horizontally splitted windows
$ vim * -o

# To open all files in a dir in vertically splitted windows
$ vim * -O

Tabs

# Open files in tabs
vim -p file1 file2 file3

# Close a tab
:tabc

# Edit a file in a new buffer
:e filename 

# go to next buffer
:bnext (or :bn)

# go to previous buffer
:bprev (of :bp) 

# delete a buffer (close a file)
:bd

# To open another tab
:tabe file.rb

# Move to the next tab
gt # or gT

Windows

# Open a file in a new buffer and split window
:sp filename 

# Vertically split window
:vs filename

# Quit a window
<C-w>q 

# Split windows vertically
<C-w>v 

# :new horizontal split (editing a new empty buffer)
<C-w>n

# :split window horizontally (editing current buffer)
<C-w>s 

# :vsplit window vertically (editing current buffer)
<C-w>v 

#  :close window
<C-w>c

# close all windows, leaving :only the current window open
<C-w>o

# go to next window
<C-w>w

# go to previous window
<C-w>p

# go to window above
<C-w><Up> 

# go to window below
<C-w><Down>

# go to window on left
<C-w><Left>

#  go to window on right
<C-w><Right>

7
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
7