Loading ...
Sorry, an error occurred while loading the content.

86260Re: vim7 chokes on simple text file

Expand Messages
  • Tony Mechelynck
    Jan 6, 2008
    • 0 Attachment
      Daniel Fetchinson wrote:
      >> I guess Vim isn't optimized for the handling of 27511-character lines.
      >> I tried:
      >> :filetype indent off
      >> ggVGgq
      >> (reformat the whole file). It went slowly, but after that the "temporary
      >> hangs" disappeared completely. So I tried
      >> :filetype indent on
      >> :w
      >> :e
      >> ggVGgq
      >> which added enormous lots of tabs, especially near the end. I had to undo.
      >> The (first) reformat apparently adds linebreaks only where there are spaces,
      >> which isn't ideal for such an uglily-written file. I can only say that (as
      >> someone who, 30 or 40 years ago, often had to take up COBOL programs written
      >> by other people and make them "work right") I totally disapprove with the
      >> "coding style" of whoever wrote that JS program.
      > I agree, it's not the best choice for having that many characters in a line.
      > How would I make vim break these lines up into shorter pieces so that
      > the javascript logic doesn't break (i.e. no line breaks on words but
      > only around ( { ) } and such signs)?
      > Cheers,
      > Daniel

      maybe (untested)

      " add space before ( [ { when preceded by non-whitespace
      :%s/\S\zs[[({]/ \0/g
      " add space after ) ] } ; , . when followed by non-whitespace
      :%s/[])};,.]\ze\S/\0 /g
      " reformat
      :normal ggVGgq

      I think we cannot be sure that the line will never get broken between
      "ordinary" words, but this will increase the number of "possible line-breaking
      positions" near punctuation.

      The reformat operation may act differently depending on whether
      filetype-indenting is in effect.

      Best regards,
      hundred-and-one symptoms of being an internet addict:
      216. Your pet rock leaves home.

      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 13 messages in this topic