Wednesday, February 11, 2015

Re: Use contents of register in search?


On Wed, Feb 11, 2015 at 7:50 PM, Tim Chase <vim@tim.thechases.com> wrote:
On 2015-02-11 16:01, Brian L. Matthews wrote:
> Sweet! That's exactly what I'm looking for. I didn't know about
> ctrl-R, that seems like it will be generally useful.

It also works in Insert/Replace mode as well, so you can dump the
contents of *any* register (not just the letter-named registers, but
filename-registers, system-clipboard registers,
expression-registers) at your current location in the text.  And as a
side usefulness of this, the expression-register is great for
inserting the results of math:

  <c-r>=8*1024*1024<cr>

will insert the actual value of 8 gigabytes in bytes.  Or

  <c-r>=system('which bash')<cr>

to insert the results of calling "which bash".

This is another of those vim features that, once you start to use it,
drives you nuts when you're stuck using some other editor that
doesn't offer that functionality.


> > if you want the ugly details.
>
> I like ugly details :-), I just couldn't find them in this case.

Often the curse of vim's help.  There are some tips and tricks for
navigating the help, but sometimes if you don't know the particular
keywords, you have to ask for a hint here.  Fortunately, the breadth
of vim knowledge on the list is sickeningly strong, and we're a
friendly bunch who will try to point you in the right direction. :-)

> On the plus side, cmdline.txt (which is where :help c_CTRL-R
> takes you), looks quite useful, I'll have to read the whole file.

If I may highlight a few more favorite bits from that file to make
sure you don't miss them:

- ranges can be stacked (":$?APPENDIX?/Miles/-2" addresses the line
  found by going to the end of the file, searching backwards for
  "APPENDIX", then from there searching forward for "Miles", then
  moving back two lines).  This becomes ESPECIALLY powerful when
  combined with ":g" commands, e.g.

    :g/^CHAPTER/+3;/FOOTNOTES/-2s/foo/bar

- control+F  (":help c_CTRL-F") allows you to use the power of vim to
  edit the vim command-line (and your previous search histories).

Tim!! I have been using vim for years now and I frequently use the q{:,/,?} commands. I did not know about ctrl-f from the command line! That is fantastic! Thank you for pointing that out. I imagine I'll use this quite often now! This list really is a never-ending fountain of vim knowledge!
 

There's other useful stuff in there, but I find those two completely
leveled up how I use Vim.

Hope this sends you down dark rabbit-holes of learning and amps up
your productivity with Vim. :-)

-tim


--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment