
On 07.07.14 22:49, Russell Coker wrote:
The way vi handles lines is good for source code but not good for documents. The up/down commands should go to the previous/next line of ~80 characters not the previous/next paragraph.
Russell, there are several wrapping modes in Vim, all of them capable of satisfying your expressed need, and switching between them can be automatic (e.g. on file extension or resident directory), or manual, as desired. The mode I use does what you prefer: ----------------------- DEFAULT ----------------------- set wrap ; It is the default in vim 7.4. (Not in yours?) ; and if desired: set ww=<,>,[,] ; whichwrap: Cursor-key around line ends. (I like it.) In this mode, a new line is started when typing flows past column 80 (or `textwidth` columns, if that is set), and up/down traverses those lines. There is a small cost to using this mode, when editing paragraphs, if lines end up overlong after going back and inserting text. Then the paragraph needs trimming. I have in .vimrc: noremap ^W gq} So that ^W suffices in lieu of gq} to reflow everything to the end of the paragraph. To trim narrower for emails, this serves me: au BufNewFile,BufRead ~/Desktop/mutt-* set textwidth=72 because I use vim in mutt. (au is short for autocommand) ----------------------- VISUAL WRAP ----------------------- Or, if some document benefits from very long lines, wrapped only in the display, then you can have both cursor motions: set wrap set linebreak ; Break lines at chars in "breakat" (:h breakat) That _will_ have up/down traversing by buffer lines, i.e. jumping visually wrapped line continuations, but also allows interpolation: "Move between display lines of a long wrapped source text (buffer) line: noremap <S-Down> gj noremap <S-Up> gk I.e. <SHIFT> refines the motion. ----------------------- FLOWED ----------------------- Alternatively, when editing a purely blank-line-separated-paragraphs document, one could ignore all of the above, and just issue the command in vim: :set fo+=a (fo is short for formatoptions, and ":h formatoptions" offers: » a Automatic formatting of paragraphs. Every time text is inserted or deleted the paragraph will be reformatted. See |auto-format|. « The hints at ":h auto-format" are worth a gander. It takes but a moment to make that "set" automatic on a file extension, using "setlocal", rather than "set", if the vim session is used to edit multiple files. Alternatively, set up Alt-something to set it, and Alt-other to: set fo-=a N.B. The cursor keys work as you prefer in this case as well. ----------------------- Admittedly, eliciting that information from the on-line help is a bit of an expedition if one is unfamiliar with the editor. (A bit like plumbing manpages, really.) Erik ( Who won't change the autocommand for mutt to: au BufNewFile,BufRead ~/Desktop/mutt-* set textwidth=72 fo+=a because having to insert a blank line to defeat wrapping appended text back into the previous line (if there's space) doesn't suit emails, I find. Note to mutt users: I've moved mutt's tmpdir with: set tmpdir="~/Desktop" # If not in ~/postponed after a crash, look here. in .muttrc ) -- Every nonfree program has a lord, a master -- and if you use the program, he is your master. - Richard Stallman