Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  * select all: ctrl-a
  * copy: ctrl-c
  * spawn vim: ctrl-f ! vim enter (varies by desktop environment)
  * paste contents into vim: :.!xsel -o
  * edit text in vim
  * copy contents from vim: :%!xsel -ib
  * close vim: :q!
  * paste contents into original window: ctrl-a ctrl-v


There is no reason to use xsel. try "+p or "* p to pull into the clipboard, try "+y or "* y (edit: the spaces are just me trying to escape the asterisks for HN)

You can also easily configure vim so that simple 'y' and 'p' will operate using the system clipboard, which I do.

You don't have to spawn and close vim around each task either.

Of course vim has no way at all to reduce the amount of ctrl-a, ctrl-c, ctrl-f, ctrl-a, ctrl-v boilerplate you are doing in this example because that all occurs in some other program.


The easiest thing to do here would likely be to make an alias that runs vim -c s/^/\\=@\* which opens vim with the text from "* on the first line. You could even add a mapping like gg"* yG:qa!<Cr> to yank the new text and close vim(the space after the asterisk is to escape it, of course).

I definitely agree that having a faster way to use the system clipboard is great, but I don't like cloberring the clipboard when I do deletions and whatnot in vim, so I have <Leader><Leader> (I use ; for leader, seems like most people use ,) mapped to "* which I find much easier(;;y is so much faster than "+y for me).


This is a great idea, for optimizing this pathway. With a sufficiently programmable desktop environment, you can probably wrap it all up into one hotkey (including the select-all, cut, and paste in the original window). I'm not sure if it's quite worth doing, on first principles, but I may take a swing at it for the practice in customizing my setup.


although I've used vim for a while now, I still feel like chuckling when I see something like 'gg"* yG:qa!<Cr>' written out, because of how ridiculous it looks to anyone who doesn't use vim.


I know just what you mean, it looks absolutely ridiculous. I occasionally send coworkers very long vim macros just for the enjoyment of explaining how useful some 100-character line of gibberish is.


> try "+p or "* p to pull into the clipboard, try "+y or "* y

Very nice. I like xsel because it gives me more flexibility and uniformity (I can pipe it to/from whatever, and use it the same in the shell as in vim), but I'll probably wind up using the above for simple cases (especially if the xsel command I want isn't in my history for some reason).


I made a more detailed post below, but I would think an alias to something like vim -c s/^/\\=@\* (or @\+ I'm not sure which register you'd need to use) would be your best bet for fast editing: it should let you open vim with text from your clipboard already inserted on the first line.


You are right, piping with xsel is very cool.


you will need a vim with xclipboard though. (not on every server)


   f 24 ^M      - choose reply
   f 6  ^M      - enter text buffer
   ^i           - open vim
   *** write this message ***
   :wq          - message gets transplanted into text buffer
   esc, esc     - exit text buffer, exit insert mode
   f 7 ^M       - choose reply again

   ??? 

   profit       - vimperator


pentadactyl user here.

I'd replace your second step with 'gi'. Saves a char, and avoids scanning for numbers..


8 steps is hardly efficient. That's not a nice flow to edit every text field where you want a more powerful editor.


Eh, most of the time what I write in a text field is short enough I'm not really going to be editing it. When I find myself writing paragraphs, I do something like the above. I agree that it's not ideal, but it suffices.


The biggest pain point I have with the constant copying back and forth is when I'm editing something that live previews in the text field or that needs to be executed. There are times when I just want to embed vim when editing code in a browser.


I use the pentadactyl extension for firefox, and I've added the emacs hotkeys <C-a>, <C-e>, <C-n>, <C-p>, <C-f>, <C-b>, <M-f>, and <M-b> to insert mode so that I can at least move between lines and words without much problem. It's not vim, but it makes things like writing this comment a lot easier for me.

Also having <C-p> and <C-n> as up and down means that moving between search suggestions on sites is really easy, which is nice.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: