gVim Commands

gVim is the graphical version of vim, which is the improved version of vi.

Getting Started

gVim can be found in the directory /usr/usc/vim/.

To set up gVim using a default USC csh or tcsh shell, run the command source /usr/usc/vim/default/setup.csh.
If you want to set up your enviroment to always set up gVim for you,
put these lines at the end of your .login file:

if (-e /usr/usc/vim/default/setup.csh) then
source /usr/usc/vim/default/setup.csh

If you use a bourne shell, such as sh, ksh, or bash, run the command . /usr/usc/vim/default/setup.sh.
To set it up permanently, add these lines to your shell’s login script:

if [ -r /usr/usc/vim/default/setup.sh ] ; then
. /usr/usc/vim/default/setup.sh

Now you should be able to start the command gvim

Note: In order to use gvim, you will need to be using an X-Windows compatible environment, such as those found on a SUN workstation, X-win32 on a PC, or X11 on a Mac. If you do not have such an environment, you can still use vi or vim, but not gvim.

Using gVim

Once you have your environment set up from the previous section, all you need to do is type gvim or add an amperstand (shift-7) in order to get your command prompt back: gvim &. You can have gVim start and automatically open a file named filename by typing gvim filename.


Once in gVim, you will see a menubar like in many familiar graphical applications. Using gVim is much easier to use for people familiar with graphical applications on Windows and MacOS. Next to every menu item is a keyboard shortcut to execute that function. gVim allows a new user to easily find common functions through the menu bar, but also gives the user the keystrokes that access the function faster, and are compatible with vim and usually vi.

To start using gVim, a user will first need to understand the modes of vi. You can start by opening a or creating a new file from the file
menu. Once the file is open, you will need to be in insert mode in order to add text to the file. You can enter insert mode by pressing INSERT, i, or
a. To stop editing and get back to the original command mode, press ESC. To enter status line mode in order to type longer commands, use the : key from within command mode.

vi Compatible Commands

Note: n will repeat the last search, whereas <n> represents a number to be typed in that generally sets the number of times a command is repeated.
The <n> is optional, and is assumed to be 1 if not present.

Leaving Vi

exit from vi saving changes

exit from vi saving changes

quit from vi (only if no changes made)

force quit from vi (without saving changes)

Note: You can also use the save and exit functions from the file menu.

Moving Around in Vi

or left arrow
move left one character

or right arrow
move right one character

or up arrow
move up one line

or down arrow
move down one line

move down half screen

move up half screen

<n> Control-f
scroll forward <n> screens

<n> Control-b
scroll backward <n> screens

go to top of file

go to bottom of file

<n> G
go to line # <n>

move to beginning of the line

move to end of the line

<n> w
forward <n> words

<n> b
backward <n> words

Note: You can also move around through gVim by using the mouse and the scrollbar.


insert at cursor

open new line below current line

open new line above current line

exit insert mode (stop inserting)


<n> x
delete <n> characters

<n> dd
delete <n> entire lines

<n> dw
delete <n> words

Changing and Replacing

<n> cw
change <n> words

<n> cc
change <n> entire lines

replace old string with new string on
current line (replaces first occurrence
on line only)

replace old with new globally (lines 1–$
means all lines and g means all occurences
on a line.)


forward search for pattern

backward search for pattern

repeat last search

Yanking and Pasting

mark current line with an x (x can be any

return to line marked with x

delete from line marked x to current line

yank from line marked x to current line

<n> yy
yank <n> lines starting at current

paste yanked lines below current line

paste yanked lines above current line


undo last change

repeat last change

join current line and next line together

report line number information

refresh screen

:w filename
write file out to filename

:r filename
read in filename below current line

vim Only Commands

:syntax on Turns on file-specific syntax colors


Note: The vim color syntax contains many bright colors, and seems best suited for a black background. You can start gvim with a black background by typing gvim -bg black -fg white &, where -bg represents the background color, -fg represents the foreground (basic text), and the & returns your command prompt.

More Help

Tips and more info are available at www.vim.org