Save and quit the easy way

Shift ZZ

-7
By: techie
2013-06-06 14:33:44

These Might Interest You

  • Search for one/many words on commandlinefu, results in vim for easy copy, manipulation. The -R flag is for readonly mode...you can still write to a file, but vim won't prompt for save on quit. What I'd really like is a way to do this from within vim in a new tab. Something like :Tex path/to/file but :cmdfu search terms


    3
    cmdfu(){ curl "http://www.commandlinefu.com/commands/matching/$(echo "$@" | sed 's/ /-/g')/$(echo -n $@ | base64)/plaintext" --silent | vim -R - }
    MeanderingCode · 2012-02-10 16:26:47 0
  • You can display, save and restore the value of $IFS using conventional Bash commands, but these functions, which you can add to your ~/.bashrc file make it really easy. To display $IFS use the function ifs shown above. In the sample output, you can see that it displays the characters and their hexadecimal equivalent. This function saves it in a variable called $saveIFS: sifs () { saveIFS=$IFS; } Use this function to restore it rifs () { IFS=$saveIFS; } Add this line in your ~/.bashrc file to save a readonly copy of $IFS: declare -r roIFS=$IFS Use this function to restore that one to $IFS rrifs () { IFS=$roIFS; } Show Sample Output


    2
    ifs () { echo -n "${IFS}"|hexdump -e '"" 10/1 "'\''%_c'\''\t" "\n"' -e '"" 10/1 "0x%02x\t" "\n\n"'|sed "s/''\|\t0x[^0-9]//g; $,/^$/d"
    dennisw · 2009-10-10 22:41:35 0
  • These series of commands allows you all at once to make a backup of your current config, edit that config, then saves it as the running config and makes it persistent. I would advise knowing what your doing to the config before running this because if you mess up say the port 22 portion, you may get knocked off the system. ;) Don't say I didn't warn ya!


    0
    iptables-save > iptables.current; vi iptables.current; iptables-restore iptables.current; service iptables save
    bigc00p · 2013-12-04 18:41:48 0
  • man nautilus (1) - the GNOME File Manager OPTIONS -q --quit Quit Nautilus. ps But if it hang up, you should kill it with -9 of couse


    0
    nautilus -q
    deasc · 2009-08-23 10:38:30 0

What Others Think

You should explain when is vim related... Anyway, this one is well-known, same as ZQ.
MarxBro · 262 weeks and 6 days ago
Also I never do it since I can make a mistake with it being that quick. I do the :qw knowing every time I use q it is quitting.
baldfat · 262 weeks and 6 days ago
Nevertheless it's the fastest way to leave vim; and yes: it's well known ;-) So +1
danimath · 262 weeks and 1 day ago
Watch out guys, if you point out that his commands are stupid, he will get butthurt vote down all your commands. Take it from me.
malathion · 262 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

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.

Share Your Commands



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: