Oh this is what that is! I accidentally reach this mode now and then and wonder how I got there and what it does. I must be accidentally pressing q: instead of :q ! This is great and useful. Thanks!
You can get to search history mode this way too. E.g.:
q/ - Search string history
q: - Ex cmdline history
q? - Search string history
Also note that if you normally use Ctrl-C to exit Insert mode, that fails here as Ctrl-C will close the history buffer. You need to use Escape or Ctrl-[.
another way to get into this mode is to start doing a complex command.. so
:%s/
and when you realise it's not as simple as you first thought.. doing ^f will take you "command line" buffer where you can do all the normal vim commands..
as for copy/paste .. if your vim is compiled with the option "+clipboard" then you can use the "+" register to interact with all your system copy/pasting..
however, what I most frequently end up doing is entering paste mode (:set paste) and just using my terminal emulator's paste buffer.. you can also sync these using tmux's buffers etc if you want, but it's a little less elegant imo..
once you have set/unset paste mode aliased to something sensible it makes the whole process as simple as it gets imo
Do you have any idea how many tutorials there are out there that involve some kind of obscure plugin or xclip incantation for something as simple as pasting text over ssh with formatting?
To think all I needed to do was :set paste... Extraordinary.
... That only applies if you haven't moved your cursor to a line in the command history which doesn't have commands. Otherwise just hitting <enter> will run that command line. So it's safer to tell people to enter :q<enter>
The title "pasting text into vim" is kind of wrong.
This isn't really about pasting text into vim, that is a very easy thing you learn in your first hour of vim (press p or at worst "+p).
It is about the more meta activity of pasting text (e.g. representing a vim command or an argument to a vim command) into the vim command line.
the ti/te sequences are passed from Vim to the client which tells Putty (and others) to bracket all pasting with \e[200~ and \e[201~. The other commands handle these sequences to make pasting happen transparently without having to hit F2 ;o)
You can also put window configurations into registers. C-x r w r puts your current window configuration (what windows you have open, their sizes and the positions in their buffers) into register r and C-x r j r jumps to that configuration.
I personally find this extremely useful--I use it far more than any other register-based feature. Of course I effectively use Emacs as my window manager for everything except web browsing, ergo I am certifiably insane.
And if ezbl or a similar project ever matures, I might start browsing from Emacs too :P.
FWIW, The + and * registers appear to behave the same on gvim for windows. I think * is actually expected to represent the system clipboard.
:help clipboard
Also another AWESOME tip , if you set an "a" among your guioptions, your visual selects and mouse selects automatically get copied to the * register.
: help quotestar
I realize that X environments mainly do this already, but not the visual select. Most of my editing is through SSH so I don't get to use the gui features much. The only time I use gvim is in windows, so it was pretty revolutionary for me.
Of course it only works for non-terminal vim. Someone may make it work on Mac though by leveraging pb{copy,paste} in some clever way (can't remember the X11 equivalent ATM)
I believe the special + register for the system clipboard is enabled by a compile option, but that may not be entirely accurate. I have Vim 7.3 installed via Macports and it works for me.
Yes, it's the "+clipboard" option (as shown by :version). If you weren't doing macports (or brew) already, the downloadable MacVIM version does include a "Vim" binary that's usable on the commandline. Somewhere in /Applications/MacVIM.app/... (can't check at work). Just symlinking or simply setting `alias vim='<path_to_binary>` works perfectly.
While the top voted answer is very complete, I prefer editing the command history.
In normal mode, type:
This will give you a list of recent commands, editable and searchable with normal vim commands. You'll start on a blank command line at the bottom.For the exact thing that the article asks, pasting a yanked line (or yanked anything) into a command line, yank your text and then:
(get into command history edit mode, and then (p)ut your yanked text into a new command line. Edit at will, enter to execute.To get out of command history mode, it's the opposite. In normal mode in command history, type: