This link has been bookmarked by 49 people . It was first bookmarked on 26 Dec 2007, by reckoner reckoner.
-
29 Oct 11
-
27 Sep 11
-
30 Jul 11
-
Pasting From GUI
-
When pasting code from a GUI application (a web browser for example), Vim mysteriously inserts a lot of extra white spaces into code. This happens because Vim thinks that you are actually typing and not pasting, so it indents the code again, resulting in more white spaces. To solve this problem, run the following command in normal mode before pasting:
-
:set paste
-
Now press
ito switch to insert mode and paste your code. Once done, you may disable this by using: -
:set nopaste
-
Map Commonly-Used Tasks to Keys
-
If you find yourself re-typing the same command over and over, why not map it to one of the function keys? To do so use the
mapset of commands: -
:map <fx> cmd
-
This maps the command
cmdto function keyFx.nmap,imapandvmapcan be used to limit key mapping to normal, insert, and visual modes respectively. -
Multiple Clipboards
-
You may use registers to simulate multiple clipboards for copy and paste operations. Register names consist of one letter or number. To yank the current selection in visual mode to the register
a, use"ay. To paste the contents of registera, use"ap. The same applies to other registers ("iyand"ip, for registeri). To view contents of all registers, use::reg. -
To visually check the difference between two files, use
-
It provides a nice color-highlighted view with code folding, much better than plain diff.
-
vimdiff file1 file2
-
-
18 Aug 10
-
:set paste
-
:sp filename
-
zf5j. -
olded text, press
zowhile the cursor is at the above line. To close it back, presszc. -
- SuperTab: Makes all insert-mode completion done with tab. To use, simply press
TABwhile in edit mode. - minibufexpl: Adds a buffer explorer to the top of Vim's window, simplifies working with buffers.
- taglist: A source code browser that works with many languages, including C/C++, Java, Python, Perl, PHP, ...
- vcscommand: SVN/CVS integration
Vim can be enhanced by plugins; the following is a list of plugins that I believe would improve the Vim experience while working with code. You may find more at Vim Scripts. To install a plugin, search for it in your package manager (Linux/Unix users) or refer to
:help add-plugin. - SuperTab: Makes all insert-mode completion done with tab. To use, simply press
-
quickly get out of command-line, press
ctrl+c. -
To auto-indent the current line, press
==
-
-
15 Aug 10
-
14 Jan 10
-
zb,zt, andzzscroll the screen to make the current line at the top, bottom, or middle. -
to auto-indent a piece of code, highlight it in visual mode, and press
=. To auto-indent the current line, press==.
-
-
04 Jan 10
-
25 Aug 09
-
21 Aug 09
-
20 Jul 09
-
23 Jun 09
-
22 May 09
-
18 Apr 09
-
26 Mar 09
-
25 Feb 09
-
05 Feb 09
-
03 Dec 08
-
24 Nov 08
-
05 Nov 08
-
29 Sep 08
-
23 Sep 08
-
10 Aug 08
-
08 Jun 08
-
Visual Blocks
Visual blocks are one of those features that you won't find in a GUI text editor. They let you mark blocks of text and do editing operations on them. To enter visual blocks mode, press
ctrl+v, then use HJKL or arrow keys to highlight a block of text. Now operate on the first highlighted line as if you were in normal mode, and operations will be reflected on other highlighted lines. For example, to indent a block of text with > characters (to make it look like a text being replied to), highlight the first column of characters in visual blocks mode, then pressshift+ito switch to insert mode at the beginning of the line. Insert a > in the first line and pressctrl+c. A > will be prepended to all other highlighted lines.This feature is also useful for commenting blocks of code, by prepending lines with // or #.
-
-
16 Apr 08
-
05 Mar 08
-
26 Dec 07
-
- SuperTab: Makes all insert-mode completion done with tab. To use, simply press
TABwhile in edit mode. - minibufexpl: Adds a buffer explorer to the top of Vim's window, simplifies working with buffers.
- taglist: A source code browser that works with many languages, including C/C++, Java, Python, Perl, PHP, ...
- vcscommand: SVN/CVS integration.
- SuperTab: Makes all insert-mode completion done with tab. To use, simply press
-
- to auto-indent a piece of code, highlight it in visual mode, and press
=. To auto-indent the current line, press==. - Use
gqto wrap the highlighted peice of text.
- to auto-indent a piece of code, highlight it in visual mode, and press
-
-
03 Nov 07
-
29 Oct 07
-
26 Oct 07
-
22 May 07
-
01 Feb 07
-
23 Oct 06
-
17 Oct 06
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.