(only when vim has been compiled with +clipboard)
Edit the files, each in a separate tab. use gT and gt to move to the left- and right-tab, respectively. to add another tab while editing, type ':tabe filename'
On command mode in Vim you can save parts of the current buffer in another file.
* The 'n' value represents the first line of the new file.
* The 'm' value represents the last line of the new file.
* newfile.txt is the newfile.
The results are similar to this command in perl:
perl -ne 'print if n..m' in.sql > out.sql
Info has some of the worst keybindings I've ever seen. Being a vim user, I attribute that to emacs influence. Use the --vi-keys option to use some of the vi keybindings, although this won't change all the keybindings. Use the "infokey" program to have more control over info keybindings.
usage: :[rang]ret[!][tabstop value] python is indent sensitive, after command :set list you may see your codes are mixed with tab and space ret can help you to convert space to tab or tab to space
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:
d%
To replace text between pairs of braces, brackets, or parentheses, issue the command:
c%
You can also use this command to find out if an opening brace has been properly closed.
-o acts like :spit. Use -O (capital o) for side-by-side like :vsplit. Use vim -d or vimdiff if you need a diff(1) comparison. To split gnu Screen instead of vim, use ^A S for horizontal, ^A | for vertical.
Calls sudo tee like all the other lines, but also automatically reloads the file. Optionally you can add command Wq :execute ':W' | :q and command WQ :Wq to make quitting easier
Here is the full function (got trunctated), which is much better and works for multiple queries. function cmdfu () { local t=~/cmdfu; until [[ -z $1 ]]; do echo -e "\n# $1 {{{1" >> $t; curl -s "commandlinefu.com/commands/matching/$1/`echo -n $1|base64`/plaintext" | sed '1,2d;s/^#.*/& {{{2/g' | tee -a $t > $t.c; sed -i "s/^# $1 {/# $1 - `grep -c '^#' $t.c` {/" $t; shift; done; vim -u /dev/null -c "set ft=sh fdm=marker fdl=1 noswf" -M $t; rm $t $t.c } Searches commandlinefu for single/multiple queries and displays syntax-highlighted, folded, and numbered results in vim. Show Sample Output
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.
In edit mode, toggle the case of a single word under the cursor in vim.
Open a CLI file explorer by splitting up your screen inside your vim session. Besides, you probably are never going to forget this one. Show Sample Output
If you need to delete lines that may contain space characters (such as tabs or spaces) as well as empty ones, try:
:v/\S/d
Just an alternative.
For editing files added to the index:
vim `git diff --name-only --cached`
To edit all changed files:
vim `git diff --name-only HEAD`
To edit changed files matching glob:
vim `git diff --name-only -- '*.html'`
If the commands needs to support filenames with whitespace, it gets a bit hacky (see http://superuser.com/questions/336016/invoking-vi-through-find-xargs-breaks-my-terminal-why for the reason):
git diff --name-only -z | xargs -0 bash -c '</dev/tty vim "$@"' x
The last part can be put in a script named e.g. vimargs, and used with any command outputting NUL separated filenames:
git grep -lz foobar | vimargs
You can then switch from a file to another with ^W^W
the middle command between the ; and ; is the vi commands that insert that line into the last line of the file, the esc with the carets is literally hitting the escape key, you have to have the smbfs package installed to do it, I use it to access my iTunes music on my mac from my linux PC's with amarok so I can play the music anywhere in the house. among other things, it allows you to access the files on that share from your computer anytime you're on that network.
I often use "vim -p" to open in tabs rather than buffers.
If you are in ex mode in vim i.e. you've pressed ':'. You can edit the current command by pressing <ctrl-f>
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.
Within vi allow to empty a text file in one shot
src: daily vim blog
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!!
commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.
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: