http://www.vim.org/tips/tip.php?tip_id=11 In insert mode, type Ctrl-N Ctrl-P
Finally, some editing commands!
| Command | Purpose |
|---|---|
| J | Joins two lines |
View command line history:
:his
View search history (Think of the forward slash as representing the search command)
:his/
The help for vim is really helpful, but just like the rest of the application, you should learn how to use it.
| Key | Command |
|---|---|
| I | insert text at beginning of line (before first blank) |
| i | insert text before cursor |
| A | insert text at end of line |
| a |
_vimrc file w/your settings in it.
Edit $HOME/.vimrc, and put preferences in there.
Get a list of options and their descriptions:
:options
| Command | Description |
|---|---|
| . | Repeat last command |
Ctrl-U, Ctrl-D : Move Up/Down one screen
You can move to X percent of the file with
X%
Move to line X
XG
| Key | Purpose |
|---|---|
| % | jump from an open brace to its matching closing brace. Actually, % can jump to many different matching items. It is very useful to check if () and {} constructs are balanced properly. |
| [{ | jump back to the ”{” at the start of the current code block. |
| gd | jump from the use of a variable to its local declaration. |
| [[ or ]] | Forward / backward next section. (Use for C functions?) |
CTRL-O takes you back to older positions, CTRL-I to newer positions.
Ctrl-G Shows the cursor's location / line number as a % of the file
Open a new tab
:tabedit
Jumps are the last X places that you've jumped to. When looking at the list of jumps / changes, the ”>” character shows what jump/change you're on. You have to use Ctrl-O or Ctrl-I depending on whether you want to move back in the list from the ”>” point. Kinda complicated.
| Command | Description |
|---|---|
| :changes | Show list of changes |
| :ju[mps] | Show list of jumps |
| `` | Jump to last mark |
| '' | Jump to start of the line of the last mark |
| `. | Jump to last modification |
| [n]Ctrl-0 | Jump to n previous position |
| [n]Ctrl-I | Jump to n next position |
| [n]g; | cycle thru recent changes (oldest first) |
| [n]g, | cycle thru recent changes (newest first) |
Execute an external command:
:! <command>
Example:
# Changes mode of current file in vi to 755 :! chmod 755 %
Two ways to suspend Vi:
Why is this? What's the difference?
Suspend Vim by typing Ctrl-Z. Shell will appear.
Use 'jobs' to list processes
> jobs [1]+ Stopped vim do.pl [2]+ Stopped vim dookie.pl
Use 'fg' to bring last background process to foreground
> fg
Or, use fg x where x is the process number to bring process number x to foreground.
> fg 1
will restore do.pl from example above.
Use :sh to go to shell
:sh
Use exit to go back to vi (Although why anybody would want to go back to vi is beyond me)
> some shell comand > exit
Geek term for “files”
| Command | Description |
|---|---|
| :e <filename> | Open a new file in current buffer |
| :e! | Reloads current file without saving changes. “Revert” or “Reload” would be more appropriate of a command name. |
| :w [filename] | Saves changes to current file, or if filename is supplied, runs Save As filename on current buffer |
| :1b | Goto buffer 1 |
:buffers, :ls, :files | Show buffers |
| :bn | goto next buffer |
| :bp | goto previous buffer |
| :[n]b | goto n buffer listed in :buffers output |
| :[n]bd[elete][!] | Remove buffer n from buffers. Postfix with ! to force. |
Windows are actually the text/divided things inside a Vim “window”.
Ctrl-V puts vim in column mode.o to move cursor from beginning of selection to end.O to move cursor to opposite corner of selection.gv in Normal mode to restore your previous selection. ’< and ’>.:’<,’> write joke.txt
Backspace key doesn't want to erase stuff in insert mode sometimes.
u Undocontrol-R RedoYou can find the HEX, Octal and Decimal value of the char under the cursor by using
ga
~/.vimrc
From http://www.ph.unimelb.edu.au/~ssk/vim/options.html
The environment variable "$VIM" is used to locate various support files, such
as the on-line documentation and files used for syntax highlighting. For
example, the main help file is normally "$VIM/doc/help.txt".
To avoid the need for every user to set the $VIM environment variable, Vim
will try to get the value for $VIM in this order:
1. The value defined by the $VIM environment variable. You can use this to
make Vim look in a specific directory for it's support files. Example:
> setenv VIM /home/paul/vim
2. For MSDOS and Win32 the environment variable $HOME is used, when defined.
Works just like setting the $VIM environment variable.
3. The path from 'helpfile' is used, unless it contains some environment
variable too (the default is "$VIM/doc/help.txt": chicken-egg problem).
The file name ("help.txt" or any other) is removed. If it then ends in
"/doc", this is removed too.
4. For MSDOS, Win32 and OS/2 Vim tries to use the directory name of the
executable. If it ends in "/src", this is removed. This is useful if you
unpacked the .zip file in some directory, and adjusted the search path to
find the vim executable.
5. For Unix the compile-time defined installation directory is used (see the
output of ":version").
| Page | Description | Tags |
|---|---|---|
| Command Line Window | This is one of the most annoying things that happens to me. <http://www.vim.org/htmldoc/usr_20.html#20.5> I always accidentally type q: in normal mode, and it… | vim |
| Cursor Line | Many editors have the ability to highlight the entire line that your cursor is on. In Vim, you can do this by using :set cursorline You can turn it off by us… | vim, cursor, highlighting, syntax |
| Fuzzy Finder | One of the best Vim plugins that I've used. Allows you to easily search for files by name, like Cmd-T in TextMate and Find File in Project in UltraEdit * <… | vim, plugins, favorites |
| Fuzzy Finder Kludge | I'm a fan of the Fuzzy Finder plugin for Vim. I have written a kludge to the Fuzzy Finder that will trim really long directory names from the entries that you … | fuzzy, vim |
| Fuzzy finder textmate | An excellent Vim plugin that improves on FuzzyFinder plugin. <http://github.com/jamis/fuzzyfinder_textmate/tree/master> I wish that foos_controller.rb would b… | vim, plugins |
| Highlighting Search Text in Vim | I generally like to highlight text that I search for. But, there's times where I don't. In the example below, I think there's too many highlighted def stateme… | vim, blog |
| IdeaVIM | Allows you to use Vim-interface from within IntelliJ IDEA. * <http://ideavim.sourceforge.net/> You get the code formatting features of Idea, as well as som… | idea, vim, plugins |
| IdeaVIM Readme | I copied the README file from version .11.6 for IDEA 7.x. See also the help file that's installed with the plugin. After you install the plugin, go to the IDE… | vim, idea, plugins |
| Lookupfile | Lookupfile is a Vim plugin that searches for files as you type criteria. For example, if you type “b”, then lookupfile will show all files that start with … | vim, plugins |
| Netrw | Netrw is the name of vim's file-browser. * <http://vimdoc.sourceforge.net/htmldoc/pi_netrw.html> Netrw has a lot of functionality, but it's like Vim in tha… | vim, netrw |
| Text/Terminal Mode | I like the text-based dialogs better than the GUI ones. Mainly because it keeps the dialogs consistent whether I'm using MacVim or Vim from a terminal. Anothe… | vim |
| URL Helper | I put this note here to help myself gain an understanding of rails and how everything fits together. <http://api.rubyonrails.com/classes/ActionView/Helpers/Url… | rails, api, vim |
| Vim - Convert To HTML | In MacVim, you can go to the Syntax Menu, and select “Convert To HTML” This will take the current file that you have open, and create an HTML document with… | html, vim, favorites |
| Vim Best Of | This is my own version of best of Vim. It is meant for real Vim “addicts”, and people who are text-editor dorks. I compiled it as a list of references to … | vim, tips |
| Vim Capture Command Output | Sometimes, you'll issue a command in Vim, and the output is piped to more, so you can't really search/filter through the output. For example, try :set all An… | vim, filter, redirection |
| Vim Clipboard | One of the biggest things that confused me about Vim was how to copy/paste stuff from other programs into Vim and vice-versa. Vim was designed in 1976?, way be… | vim, clipboard |
| Vim Colorschemes | <http://www.vim.org/htmldoc/usr_06.html> This website <http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/index-c.html> is a great place for previews of colors… | vim, colorschemes, skins, themes |
| Vim Customizing | There are thousands of ways of customizing Vim, which is both good and bad. * You can customize your settings: Vim Settings * For a list of keys that are … | vim, mapping, keyboard |
| Vim Defaults | Very good basic article on configuring best defaults in Vim: * <http://items.sjbach.com/319/configuring-vim-right> Notesmine External vim | vim |
| Vim Diff | Vim can be used to show diffs From <http://mamchenkov.net/wordpress/2004/05/10/vim-for-perl-developers/2/> Vim will show both files in vertical split window m… | vim, diff, vim, diff |
| Vim Formatting | Vim has some pretty cool formatting things. The gq command formats the {motion} that you tell Vim to do. gq is used to format “normal” text (as opposed to… | vim, formatting, syntax |
| Vim Help | * <http://www.truth.sk/vim/vimbook-OPL.pdf> * Use :help <command> to get help for a particular command. Default is to get help for the normal mode comma… | vim, vim |
| Vim Insert-Mode Completion | Also known as “Autocomplete”, and “Code Completion” See <http://vimdoc.sourceforge.net/htmldoc/insert.html#ins-completion> After using text editors/ID… | vim, autocomplete |
| Vim Keyboard Mapping | The :verbose map command shows where a key sequence was mapped. This is handy for resolving key conflicts. Shows where ;1 was mapped, if at all. :verbose map… | mapping, vim, keyboard |
| Vim Motion | This is a huge area, and my favorites are for coding, where you can jump back & forth to the start of if .. then blocks, methods, and start/end of classes. The… | vim, motion, navigation, jumps |
| Vim Obscure | This page is a list of the “obscure” commands in Vim. (Yes, I realize that most commands in vim are obscure) :history : list of all your commands… | vim, obscure, favorites |
| Vim Options | Much of Vim's functionality is done through options. You can see the value of an option by using the :set command, with a question mark after the setting. Thi… | vim, favorites |
| Vim Plugins | Plugins extend the functionality of Vim. Plugins for any software tool are often tricky to install/use, sometimes have bugs, etc. However, if a plugin is wide… | vim, rails, ide, plugins, vim, editors, ide, plugins |
| Vim Rails | Great vim plugin for rails applications. There's an excellent Tutorial on , and I recommend you navigate through that to learn how to install and use. I liste… | todo, vim, rails, ruby, ide, todo, vim, rails, ruby, ide |
| Vim Rails Screencast | I might create a screencast showing how to use Vim w/Rails. * Show Vim setup? -- No * Show where to get Rails & related plugins? - Yes * Create Rails ap… | vim, rails, screencasts |
| Vim Scrolling | One of the coolest things about Vim is its ability to show you where you are easily. The commands on this page do not move your cursor, instead they move the t… | vim, scrolling, cursor, movement |
| Vim Settings | Vim has a gazillion settings/options that you can use. With Vim, there's not really any “Options” window. You have to set the options yourself, or use a c… | vim, vimrc, vim, vimrc |
| Vim Sorting | I got this tip from here: <http://weblog.jamisbuck.org/2008/10/10/coming-home-to-vim#comments> One of my favorite vim commands, and a powerful one, is this: I… | vim |
| Vim Terminal Background | Sometimes Vim's syntax looks horrible. For example, you're using a white background, and the characters are all light yellow, light red, etc. Try one of these… | vim, terminal |
| Vim Todo | This is just a page w/my TODO notes regarding Vim. It's meant to keep myself from yak-shaving when I find an aggravating thing in Vim. * Currently Ctrl-HJKL… | vim, todo |
| Vim Tricks | There are plenty of Vim tips/tricks pages out there. Here's some of my own. Say you have some text like below, and want to eliminate the blank lines: def s… | vim, tricks |
| Vim Visual Mode | Visual Mode means working with highlighted text. When you only use v to highlight text, then Vim will only copy what's highlighted. This is annoying if you wa… | vim, block mode, visual mode |
| Vim Whines | * Requires large amount of tweaking for minor, yet annoying things. * Giant white status bar that blazes your eyes out. * Plugins are nice, but usually h… | vim, whines |
| gvim and vim fonts | Bad. Font is sketchy/broken up, and too slim. I think this looks good: :-) Related Pages on Notesmine External Pages gvim, and, vim, fonts | gvim, and, vim, fonts |
| my vim setup | Just a page to list my Vim shortcuts, so I don't forget them, or have to use ”:map” to find them. * Ctrl = Control Key * D = Apple Key Current Vim Sh… | my, vim, setup |