lambdalisue / vim-gista

An alternative gist.vim, vim plugin which manipulate gists in Vim.
http://www.vim.org/scripts/script.php?script_id=4976
MIT License
156 stars 5 forks source link

Quickly yank (copy) a Gist's contents #83

Closed sh78 closed 6 years ago

sh78 commented 6 years ago

Would be great to directly yank the contents of a Gist right after :Gista list. I want to use Gist like a snippet manager.

yy is already taken, but maybe yi for "yank inside" would fit.

2018-05-12 at 17 23 59
lambdalisue commented 6 years ago

What do you expect if there are several files?

sh78 commented 6 years ago

What do you expect if there are several files?

Good point. I suppose it would be best to concatenate and yank all since that would eliminate the scenario where a user has to reopen Gista to get another file's contents. At least then they could easily just delete the portion that they don't need.

Then again there could be two actions:.

  1. ‘yi‘ - yank inner contents of first file returned by gh API
  2. ‘ya‘ - yank all files concatenated

These bindings correlate with vim's default motions, "in" and "around/all".

lambdalisue commented 6 years ago

I feel it's a bit ambiguous. For example, assume that a gist have 4 files as

  1. test.py
  2. linux.txt
  3. windows.txt
  4. mac.txt

and user want the content of windows.txt but don't know the order of appearance.

In this case, it's sometime difficult to distinguish the content and user can not determine which content comes from which.

So I don't feel the feature should be in gista itself.

For your purpose, the following simple macro would work I guess (not tested so some modification would be required)

qa
<Return>
ggVG
"ay
<C-^>
<C-w>p
q

then press @a. Once you satisfy, write it to the buffer local function or whatever.

sh78 commented 6 years ago

Fair enough - I didn't realize gists could have multiple files originally.

Thanks for typing up that macro @lambdaalisue! I'll make a key mapping for my snippet management.