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/
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.
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
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:
vim can open ssh/sftp and ftp connections for file editing using 'netrw'. If no path or file is provided vim opens the directory as a filelist.
See: :help netrw.
Paste what you previously wrote in INSERT MODE, for example:
1. Write 'foo' in INSERT MODE
2. Return to NORMAL MODE
3. Press "." and it will paste 'foo'
Will search for the given pattern and build a list of occurrences.
Then you can use :copen and :cclose to toggle the list.
When browsing the list, ENTER will take you to that line in the file.
The option --porcelain makes the output of git easier to parse.
This one-liner may not work if there is a space in the modified file name.
This oneliner gets all the 'modified' files in your git repository, and opens all of them in vim.
Very handy when you're starting to work in the morning and you simply want to review your modified files before committing them.
Maybe there are better ways to do that (and maybe integrated in vim and/or git, who knows), but I found quicker to do this oneliner.
Use vim's diff mode to edit two or more files in one window. The '+diffoff!' turns off diff highlighting when the session is started.
Use ctrl+w + ctrl+w to switch between windows.
Helps when I'm editing a script and want to double check some commands without having to exit out of vi multiple times or having to use another terminal session.
This was me just succumbing to the habits, but now I rarely use quit or vim directly, so beware! :)
Put the cursor on either curly braces ( {, } ). Then press d%
The d is delete command, and % is movement command that move the cursor to another matching parentheses (or curly braces in this case). This action will delete every character that was on the way of the movement (from the first curly braces to the second).
We have for example :
func () {
echo FOO
echo BAR
}
Place the cursor under a bracket and press d + %.
It will cut everything inside and the brackets.
It let : func ()
You can copy text with y + %
You're perhaps editing a line, or reading a certain line of code, you use page up and down or move through the file and now you wish to return to the last position the cursor was at. '' will get you there.
If you vim a compressed file it will list all archive content, then you can pickup any of them for editing and saving. There you have the modified archive without any extra step. It supports many file types such as tar.gz, tgz, zip, etc.