Tuesday, January 13, 2009
Delete to End of Page
Typing `dL' in normal mode will delete to the end of the current page. In other words, everything visible to the bottom of the window.
Monday, January 12, 2009
Remap Backtick
I find it convenient to remap the backtick key "`" to single-quote "'". Functionally, they are very similar. Backtick takes you to an exact mark location while single-quote simply takes you to the beginning of the marked line. I don't use the single-quote functionality much, and it's much easier to reach than backtick, so the following mapping saves some finger stretching.
nnoremap ' `
nnoremap ` '
nnoremap ' `
nnoremap ` '
Saturday, January 10, 2009
Reformat a Paragraph
Say you have the following text:
> someone said
> > someone else said
> > > long quoted message
> > blah blah
> blah
Place the cursor on the first line and do `gqip'. I often use this combo to conveniently reformat paragraphs.
> someone said
> > someone else said
> > > long quoted message
> > blah blah
> blah
Place the cursor on the first line and do `gqip'. I often use this combo to conveniently reformat paragraphs.
Friday, January 9, 2009
Modelines
Vim allows you to insert modelines to specify options you'd like for a specific file. For example, you could have a perl script as follows:
#!/usr/bin/perl
# vim: set expandtab:
use strict;
This would tell Vim to expand tabs in the current file. See :help modeline for more info.
#!/usr/bin/perl
# vim: set expandtab:
use strict;
This would tell Vim to expand tabs in the current file. See :help modeline for more info.
Thursday, January 8, 2009
Removing Ctrl-M
There are quite a few ways of doing this, but a quick way to remove ^M scattered around your file is as follows:
:%s/C-vC-m//g
Where C-v is Ctrl-v and C-m is Ctrl-m.
:%s/C-vC-m//g
Where C-v is Ctrl-v and C-m is Ctrl-m.
Wednesday, January 7, 2009
Command on All Windows
Here's a neat trick. If you want to execute an ex command on all windows, you can do the following:
:windo command
so...
:windo %s/foo/bar/g would find and replace foo with bar in all windows.
:windo command
so...
:windo %s/foo/bar/g would find and replace foo with bar in all windows.
Monday, January 5, 2009
Only RSS Vim Tips
For those of you that would prefer to exclude any tips from this blog that aren't directly related to Vim from your RSS, I have an easy solution. Blogger allows feed URLs to be filtered based on tags. I only use the vim tag on posts directly related to Vim, so the following RSS URL should be a convenient solution.
http://dailyvim.blogspot.com/feeds/posts/default/-/vim
http://dailyvim.blogspot.com/feeds/posts/default/-/vim
Subscribe to:
Posts (Atom)