Vim: Difference between revisions
From charlesreid1
No edit summary |
No edit summary |
||
| Line 2: | Line 2: | ||
See: [[wikipedia:Vim (text editor)|Vim wikipedia article]] | See: [[wikipedia:Vim (text editor)|Vim wikipedia article]] | ||
[[Vim/Notes]] | |||
[[Vim/Tabs]] | |||
=Introduction= | =Introduction= | ||
| Line 108: | Line 112: | ||
==Making Stuff== | ==Making Stuff== | ||
=References= | |||
* vimrc references: | |||
** http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html | |||
** http://www.moolenaar.net/habits.html | |||
* vimlatex reference: | |||
** http://vim-latex.sourceforge.net/index.php?subject=download&title=Download | |||
Revision as of 21:20, 20 May 2011
Vim is a very handy, full-featured, lightweight text editor available on all Unix systems. Vim and Emacs are two of the most common text editors available on Unix systems.
Introduction
Documentation
You can find plenty of documentation available for Vim here: http://www.vim.org/docs.php
You can also type :help from Vim, which will open Vim help, and you can navigate from there.
This documentation is also available online here: http://vimdoc.sourceforge.net/
Configuration
.vimrc
Main article: my .vimrc file Dotvimrc
Searching
Searching in Vim utilizes regular expressions.
Find
To search for an expression, type:
/pattern
Find and Replace
To find and replace an expression, type:
:%s/peanutbutter/jelly/g
where the g means "global", i.e. replace all instances of "peanutbutter" with "jelly" (instead of just the first instance).
Using Regular Expressions
You can also utilize regular expressions in either finding or finding and replacing. For example, you can search for a 2-digit number by using:
/[0-9][0-9]
Multitasking
Windows
Vim has a really handy feature that allows you to divide the screen of the text editor into multiple sections, called windows.
:sp - split the current window into two parts, horizontally - "top" and "bottom"
:vsp - split the current window into two parts, vertically - "left" and "right"
To open multiple files and split them into their own windows, use the -o and -O command-line options.
The following will open these 3 files split horizontally:
$ vim -o file1 file2 file3
and this will open the three files split vertically:
$ vim -O file1 file2 file3
Tabs
Like windows, tabs provide a way to handle several files at once. However, windows allow you to open and look at multiple files at once. Tabs, on the other hand, like browser tabs, allow you to look at one file at a time but still have other files open, for easy switching back and forth between open files.
Tab commands include:
:tabnew - creates a new tab and switches to it
:tabnext - go to the next tab
:tabn - ditto
:tabprevious - go to the previous tab
:tabp - ditto
:tabfirst - switch to first tab (good if you have lots of tabs open)
:tabfir - ditto
:tablast - switch to last tab
:tabf something* - find tabs with open files whose names match "something*"
:tabs - list all open tabs and what files they are open to
Interfacing with the Shell
Making Stuff
References
- vimrc references:
- vimlatex reference: