Hacker News new | past | comments | ask | show | jobs | submit login

Although I write all of my code in Vim, I have always found it to not be great environment for text. The main annoyance comes from dealing with long lines or automatic line wrapping that never seems to do what I want it to.

Does anyone have other plugins that they find useful when writing in vim?




Reed Esau creates a bunch of vim plugins for writing, I've found them to work very nice:

http://wynnnetherland.com/journal/reed-esau-s-growing-list-o...


Thank you for this link. vim-wheel is just pure gold, I needed that for a long time...


What I do is 1) use LaTeX so that I don't have to worry about lines and how they effect the final product, 2) :set wrap 3) map j and k to gj and gk, so that I can go up and down softwrapped lines like normal.

I really don't get why the behavior of gj/gk isn't the default.


I've written a lot of LaTeX and ConTeXt in Vim with one sentence per line without any problems.


I also follow this convention. One sentence, then new line. It looks a little janky, but when you run it through pandoc or whatever, it yields the way you would want.


Well since you mentioned long lines let me plug my own, because I find it a genuinely elegant solution to one related problem: http://github.com/goldfeld/vim-seek, it's a motion I created mostly to move around long lines, which were a major pain point for me especially when writing prose (and even more acutely painful back when I used soft-wrapped lines, though I still get a lot of mileage from it while using hard-wrap at 80 columns, RMS/Linus-style.)



I did not know job `gj` and `gk` for line navigation. That will definitely be useful!


Also try simply "gq" + down arrow or "gq" + up arrow to realign line lengths to the paragraph length in the up or down direction. Or you can do "gqap" to do the whole paragraph regardless or where you are located. This helps me keep pretty 80char paragraphs when writing latex or .rst or .md files, and the separate lines get merged to a single line by the text processor.

edit: To explain better, it basically re-wraps text in the optimal way into a paragraph. So you can not worry about spacing while typing and editing, and then when you are finally done you can just select the text and fix the wrapping really easily.



I find par to be very useful. http://www.nicemice.net/par/

Works great for re-wrapping code comments too.

It's been packaged in Debian for ages.


par is one of the handiest text tools around. I often use it to reformat longer quotes for HN. I just wish the documentation was a little better. I can only tell you about the two or three options that i use. I do not understand all of the other possible formatting commands and I definitely have no idea why I always set

  PARINIT="rTbgqR B=.,?_A_a Q=_s>"
The first version of par was released in 1993 and the first Debian package was in 1996. The latest release will be 13 years old on Tuesday.


gq for reflowing.

The main problem I have is when I'm authoring in vim and pasting to another editor which interprets hard returns as, well, hard returns.

Mostly I play games with piping through a formatting tool or join up lines manually before pasting them. Hrm. Now you've got me wondering if there's a good way to do that generically.


And here's what I've come up with, as ~/bin/unwrap:

    #!/usr/bin/perl -p
    
    use strict;
    
    BEGIN{$/=undef;} 
    
    { s/(?<!\n)\n(?!\n)//sg; }
    
    END {print"\n"}


> annoyance comes from dealing with long lines or automatic line wrapping

You have to set 'formatoptions' depending on what you're doing. I have a keymapping to set/unset fo+=a/fo-=a.




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

Search: