vim's pastetoggle: when you press f9 'paste' is on , press f9 again and 'paste' is off, and so forth (works in insert-mode and command-mode)

:set pt=<f9>

4
By: lionping
2010-07-19 07:19:08

These Might Interest You

  • 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'


    -3
    . (in NORMAL MODE)
    Zulu · 2013-01-08 18:32:57 0
  • You can record, then replay a series of keystrokes in vim. In command mode 'q', then a letter [a-zA-Z] starts macro recording mode. Enter a series of vim commands. When done, enter command mode again, and press 'q' to stop recording. To replay, enter command mode, then press @{letter}


    4
    <esc> q a ...vim commands... <esc> q (to record macro) @a (plays macro 'a').
    bartonski · 2010-04-02 04:33:36 0
  • Schematics: command [options] [paste your variable here] parameter command [options] [paste entire column of variables here] parameter ... (hard-code command "c" and parameter "e" according to your wishes: in example shown command = "cp -a" and parameter = "~") Features: - Quick exchange only variable part of a long command line - Make variable part to be an entire column of data (i.e. file list) - Full control while processing every single item Hints: Paste column of data from anywhere. I.e. utilize the Block Select Mode to drag, select and copy columns (In KDE Konsole with Ctrl+Alt pressed, or only Ctrl pressed in GNOME Terminal respectively). Disadvantages: You can paste only one single variable in a row. If there are more space separated variables in a row only first one will be processed, but you can arrange your variables in a column instead. To transpose rows to columns or vice versa look at Linux manual pages for 'cut' and 'paste'. TODO: - add edit mode to vary command "c" and parameter "e" on the fly - add one edit mode more to handle every list item different - add y/n/a (=All) instead of only y(=default)/n to allowed answers Disclaimer: The code is not optimized, only the basic idea is presented here. It's up to you to shorten code or extend the functionality. Show Sample Output


    -1
    c="cp -a";e="~";echo -e "\npaste\n";i=0;k="1"; while [[ "$k" != "" ]]; do read -a k;r[i]=$k;((i++));done;i=0;while :;do t=${r[i]};[ "$t" == "" ] && break; g=$(echo $c ${r[i]} $e);echo -e $g "\ny/n?";read y;[ "$y" != "n" ] && eval $g;((i++));done
    knoppix5 · 2011-12-04 12:45:44 0
  • generally we cannot use control + v to paste text copied in clipboard but by pressing control and holding it press shift and v


    -8
    <ctrl+shift+v>
    pahnin · 2010-08-08 12:48:51 5

What Others Think

*thank you!* I use and love auto-indent, but I also like pasting stuff into vim. I'll probably use this toggle 4 or 5 times a day. That went *straight* in to my .vimrc.
bartonski · 413 weeks and 2 days ago
I didn't know about the method lionping showed. Much nicer than what I had in place. I've switched. ;)
Vilemirth · 370 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: