MFreidank / AnkiVim

Use vim (or your favorite editor) to write anki cards quickly in plain text or latex.
Other
204 stars 14 forks source link

Best workflow for images ? #9

Open thiswillbeyourgithub opened 4 years ago

thiswillbeyourgithub commented 4 years ago

Hi, I have been AVIDLY interested in your addon for a while now but I can't figure out a way to quickly and efficiently add images to cards from the clipboard. Can anyone share how they do ?

If I find a compatible workflow I will probably add tons of macros into vim (neovim in my case) to emulate anki, I of course intend to share it in this repo if that happens :)

MFreidank commented 4 years ago

Hi, @thiswillbeyourgithub. Thanks for your kind words on my tool. I think I can help with your request, but let me make sure I fully grasp what you want to do. Are you trying to insert an image (file/path?) from your current clipboard into an anki card that you create? Please confirm and I will share how I do that when I create my cards. Many thanks and kind regards, MFreidank

thiswillbeyourgithub commented 4 years ago

Hi, I am really struggling to find time for anything these days but I have a few ideas of additions that would be great on AnkiVim :

They are all something I could tackle if I could find the time (CS is just a hobby for me). I intend to keep using nvim and anki for the decades to come so I will do them eventually, but I thought you might be interested in reading this :).

Now for the matter at hand.

My current setup involve reading pdfs and adding hundreds of flashcards. I sometimes have to add a picture to a field and anki supports this beautifully with a quick pasting from the clipboard.

Currently the command I use to copy the screen into the clipboard is the following : maim -s --format=png /dev/stdout | xclip -selection clipboard -t image/png -i. So I'm guessing what I'm after is a vim binding that would paste the image into the ankivim folder and link to it using the img snippet.

Am I right ?

So basically :

Are you trying to insert an image (file/path?) from your current clipboard into an anki card that you create?

Yes please.

How do you do ? Or how would you go about doing this ?

jdsutherland commented 3 years ago

@MFreidank I would also be interested in hearing about your workflow for adding images.

MFreidank commented 3 years ago

Hi @thiswillbeyourgithub @jdsutherland My own workflow for images is pretty similar to the one explained in this blog post (Section 4: Images): https://sofiabelen.github.io/blog/anki-vim.html

This post also showcases a way to cover the use-case of quickly inserting screenshots, swapping out scrot(1)for maim(1) is straightforward. One can further simplify by sending a command to vim to insert filepaths to screenshot files on disk, by having vim run in server mode.

However, note that these mostly come down to vim-side/user-side tweaks. For this reason I won't directly ship them with AnkiVim, to avoid interfering with a user's editor configuration or enforcing specific tools (e.g. scrot vs maim etc).

Please let me know if this did not answer your question or if there are doubts remaining, happy to address them.

Kind regards, MFreidank

MFreidank commented 3 years ago

@thiswillbeyourgithub Regarding your detailed list of improvements (thank you!!) I'll try to address them one by one:

thiswillbeyourgithub commented 3 years ago

Hi! Thanks for everything. I will answer point by point as well :

I've added a snippet for image filepaths. Supporting the clipboard natively is tricky, because full support would require catering to too many options: different screenshot tools, different operating systems, different types of clipboards etc. Do you believe linking to the blog post shared above would help address this by documenting a way to do it and allowing users to tweak that way to their preferred configuration?

Absolutely! This blog post shows indeed a very simple way to do what I needed. Maybe it would be more straightforward to make a wiki with a boiled down version though. Of course the wiki would link to the blog post.

Main reason for having them written out this way was to distinguish them from legitimate user content to avoid having users accidentally break content parsing. In principle, I'm open to suggestions on other ways to specify the headers.

A Very good point. Maybe an alternative would be to use colorschemes to distinguish ths fields.

That's a very legitimate point and something I have considered but did not yet get to. Would be happy to merge a community contribution for this feature!

I happen to have made pdf2anki in the past, this is terrible code but gets the job done. I recall I had trouble understanding how exactly to interact with ankiconnect so maybe taking a look at my script would help. I think there are something like 2 distinct libraries that allows to ineract like ankiconnect, I don't remember the name but some might be more straightforward to use.

  • add nvim-type marks at each field by default (like 'a for question, 'b for 2nd field, 't for tags etc) Can be done, but a bit tricky for me to develop as I do not use nvim. We'd need to ensure that these changes apply only to nvim users, as the tool is also used by people with various other editors (I am aware of plain vim, emacs, nano and neovim users and I'm not sure if that list is comprehensive). Happy to merge a PR for this as well.

Okay. I think I will just end up using either :mksession or just set the marks myself and have nvim remember it for the blank file.

  • also import the tag list and add autocompletion for those tags (I have a lot of doubts on my ability to do this, almost no knowledge of vimscript or addons) Yes, this falls under the same anki-connect integration feature that your earlier suggestion does. That integration looks promising and is something I'm intending to do in the future. Very happy to include a community contribution there as well, if you have the bandwidth to pick it up.

Unfortunately I am completely swamped for a long time (med student :( ).

  • add a functionnality like frozen field Not sure what the best design for it would be and haven't really had that use-case yet myself. Could you elaborate?

Basically, if you have a field "source" for example in which you put the link to the website you're ankifying, then having to retype the same content to the field would be a nightmare if you enter a few dozen cards from the same source. Frozen fields solves that by remembering past fields, at least those you selected.

  • snippets for more formatting features : colors, bold underline italic, bullet points, etc Personally I write most cards with fancy formatting using latex and by default my snippets extend a users tex snippets. If you'd prefer to directly have access to those features outside of latex, feel free to extend the snippets file and share your updates with us :)

I recently got more familiar with snippets so I will probably end up doing that.

Unfortunately my workload is very often too high for myself so I can't contribute and even use ankivim as much as I want to. Sorry for the false hope, but I'll make sure to contribute what I end up doing on my side to make it work. Thanks for bringing ankivim already!