What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again.

Delete that bloated snippets file you've been using and share your personal repository with the world. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/

Get involved!

You can sign-in using OpenID credentials, or register a traditional username and password.

First-time OpenID users will be automatically assigned a username which can be changed after signing in.

Universal configuration monitoring and system of record for IT.

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for:



May 19, 2015 - A Look At The New Commandlinefu
I've put together a short writeup on what kind of newness you can expect from the next iteration of clfu. Check it out here.
March 2, 2015 - New Management
I'm Jon, I'll be maintaining and improving clfu. Thanks to David for building such a great resource!

Top Tags





Commands tagged vim from sorted by
Terminal - Commands tagged vim - 141 results
<ctrl-f> in ex mode in vim
2009-09-05 14:43:15
User: Vereb
Functions: ex
Tags: vim

If you are in ex mode in vim i.e. you've pressed ':'. You can edit the current command by pressing <ctrl-f>

vimdiff <(svn cat "$1") "$1"
2009-09-04 18:41:40
User: plasticboy
Functions: cat
Tags: svn vim diff color

This will diff your local version of the file with the latest version in svn. I put this in a shell function like so:

svd() { vimdiff <(svn cat "$1") "$1"; }
find . -type f -exec grep -qi 'foo' {} \; -print0 | xargs -0 vim
2009-09-03 17:55:26
User: arcege
Functions: find grep xargs
Tags: vim find grep

Make sure that find does not touch anything other than regular files, and handles non-standard characters in filenames while passing to xargs.

find . -exec grep foobar /dev/null {} \; | awk -F: '{print $1}' | xargs vi
grep -ir 'foo' * | awk -F '{print $1}' | xargs vim
grep -Hrli 'foo' * | xargs vim
2009-09-03 15:44:05
User: dere22
Functions: grep xargs
Tags: vim sed awk grep

The grep switches eliminate the need for awk and sed. Modifying vim with -p will show all files in separate tabs, -o in separate vim windows. Just wish it didn't hose my terminal once I exit vim!!

grep -ir 'foo' * | awk '{print $1}' | sed -e 's/://' | xargs vim
2009-09-03 15:12:27
User: elubow
Functions: awk grep sed xargs
Tags: vim sed awk grep

This will drop you into vim to edit all files that contain your grep string.

vim -e -s -c 'g/start_pattern/+1,/stop_pattern/-1 p' -cq file.txt
2009-08-26 10:22:27
User: syladmin
Functions: vim
Tags: vim block

By using vim, you can also filter content on stdout, using vim's extra power, like search pattern offset!

No more awk of course, sorry.

details :

-e ex mode

-s silent

-c 'ex command' : global + start and end pattern + offset print (p)

-cq : quit

2009-08-19 11:59:22
User: slim

Whereas ^V is CTRL-V.

converts a dos file to unix by removing 0x13 characters

svn diff | view -
2009-07-25 07:13:40
User: bigeasy
Functions: g++
Tags: vim

In edit mode, toggle the case of a single word under the cursor in vim.

vim $(grep test *)
2009-07-15 10:15:04
User: goatboy
Functions: grep test vim
Tags: vim grep

I often use "vim -p" to open in tabs rather than buffers.

:let i=0 | 'a,'bg/ZZZZ/s/ZZZZ/\=i/ | let i=i+1
:r! echo %
2009-06-19 12:17:28
User: miccaman
Functions: echo
Tags: vim

insert filename

Normal mode: "%p

Insert mode: %

:source ~/.vimrc
:set nomore :argdo %s/foo/bar/g | update
svn diff <file> | vim -R -
2009-06-13 22:00:49
User: caiosba
Functions: diff vim
Tags: svn vim diff color

Simple way to achieve a colored SVN diff

2009-05-21 15:02:39
User: haivu
Tags: vim vi

This is a simple command for jumping to the matching brace, square bracket, or parentheses. For example, it can take you from the beginning of a function to the end with one key stroke. To delete everything between the pairs of {}, [], or (), issue the command:


To replace text between pairs of braces, brackets, or parentheses, issue the command:


You can also use this command to find out if an opening brace has been properly closed.

vim `which <scriptname>`
2009-05-08 17:21:47
User: bunedoggle
Functions: vim
Tags: vim which script

Often I need to edit a bash or perl script I've written. I know it's in my path but I don't feel like typing the whole path (or I don't remember the path).

vim -x <FILENAME>
2009-05-05 23:24:17
User: denzuko
Functions: vim

While I love gpg and truecrypt there's some times when you just want to edit a file and not worry about keys or having to deal needing extra software on hand. Thus, you can use vim's encrypted file format.

For more info on vim's encrypted files visit: http://www.vim.org/htmldoc/editing.html#encryption

vim ~/.purple/pounces.xml
2009-04-28 19:11:39
Functions: vim
Tags: vim pidgin

So you keep getting buzzes sounding from pidgin but you can't remember which buddy pounce is causing the beep. Well, cat/edit the ~/.purple/pounces and find out!