57

Emacs' handling of long lines is not very well optimized. For a number of operations, Emacs has to scan the whole line repeatedly. For example, to display a line, Emacs has to figure out the height of the line, which requires scanning the whole line to find the tallest glyph. Additionally, scanning for bidirectional display eats up a lot of time. You can get ...


18

Another solution is to use adaptive-wrap-prefix-mode. This way you'll see the full header and source but it will wrap nicely indented. With visual-line-mode: With visual-line-mode and adaptive-wrap-prefix-mode:


18

I did some brief experiments with this using a minified copy of jquery. font-lock-mode and flycheck-mode both contributed to slowness, as did js2-mode, and prettify-symbols-mode. line-number-mode and column-number-mode had minor effect. Once I had turned off all the different modes though the performance was relatively snappy. Use C-h m and start disabling ...


17

I've uploaded http://www.emacswiki.org/emacs/OverLongLineMode This library enables you to set simple line-length thresholds beyond which a variant of fundamental-mode will be used for a file instead of its normal mode (for programming modes only). Potentially something along these lines could be added to Emacs by default, but this can be an interim ...


13

For (1), I would use an enlarged margin, so that visual-line-mode wraps lines at the desired fill-column. This will affect both text lines and equations, though. As for (2), one can define a custom filling command to be bound to M-q and correctly fill paragraphs. I haven't yet managed to write a command with the correct behaviour for auto-filling. Wrapping ...


13

You have two three options: Use next-logical-line instead of next-line when defining the macro: Move cursor vertically down ARG lines. This is identical to next-line, except that it always moves by logical lines instead of visual lines, ignoring the value of the variable line-move-visual. Set line-move-visual to nil: (setq line-move-visual nil) ...


12

As already answered in the comments, Emacs becoming very slow in its redisplay for long lines is a well-known issue. Fixing it would be very nice, but needs lots of thought to be pulled off correctly. I have an idea of how it could be accomplished based on section 6.3 of this document (basically, store visual line information in the current buffer and ...


11

I don't know of a package that would enable this behavior, but here's one way to do it. Press C-h k C-a to discover that C-a is bound to move-beginning-of-line; this is the function we need to modify --- or just use to implement the "moving to the beginning" part. Similarly, with C-h k I can find forward-line, which will be used to move up/down. To be able ...


11

If you just want something like visual-line-mode but configurable, you can try longlines-mode which is what I use for most of my prose. longlines-mode wraps your text similarly to visual-line-mode with the width configured by fill-column. Here's a screenshot with fill-column set to 70 (the window actually extends even more to the right). Configuring fill-...


10

Alternatively to query replace you can go with multiple-cursors: Also consider using something like this: (defun wrap-html-tag (tagName) "Add a tag to beginning and ending of current word or text selection." (interactive "sEnter tag name: ") (let (p1 p2 inputText) (if (use-region-p) (progn (setq p1 (region-beginning) ) ...


9

Would your version-control issues be avoided/resolved if you use git diff --color-words or latexdiff? Then you can look at changed words.


9

UPDATE http://git.savannah.nongnu.org/cgit/so-long.git/tree/so-long.el is a part of Emacs 27.1! OLD I usually unroll long lines and indent by tags (like HTML, XML, JSON). In order to make such operation possible I add: (setq line-number-display-limit large-file-warning-threshold) (setq line-number-display-limit-width 200) (defun my--is-file-large () "...


8

Library misc-cmds.el has long had this feature. These are the relevant commands, and suggested key bindings (these bindings are made in setup-keys.el). (cond ((fboundp 'move-beginning-of-line) (substitute-key-definition 'move-beginning-of-line 'beginning-of-line+ global-map) (substitute-key-definition 'move-end-of-line 'end-of-line+ global-...


8

No. To emulate the behaviour of longlines-mode, use visual-line-mode in combination with the visual-fill-column package.


8

I expect you'll find that the difference is due to font-lock. When fontification is to be performed on the subset of the file which is visible in the window, it proceeds by first extending the fontification region such that it will include full semantic units. See the font-lock-extend-region-functions code for this. It's common for this to include extending ...


8

You can use query-replace-regexp (C-M-%). Replace ^\(.*\)$ with <li>\1</li>.


7

The most direct way of doing this would be to Mark the region of text lines to become a list Press M-% (query-replace) Type C-q C-j RET </li> C-q C-j <li> RET (C-q C-j inserts a quoted newline character) Press ! to replace all occurrences


6

You want the functions bolp and eolp for beginning and end, respectively.


5

I created my own solution for this problem here: https://github.com/rakete/too-long-lines-mode I was not satisfied with phils solution which switches a buffer with very long lines to fundamental-mode, I wanted a solution that lets me keep syntax highlighting and other major-mode features. So I created a minor-mode that uses overlays to hide most characters ...


5

This can be done by creating a custom function that checks to see whether it's on an org-heading. (setq org-blank-before-new-entry '((heading . always) (plain-list-item . nil))) (defun call-rebinding-org-blank-behaviour (fn) (let ((org-blank-before-new-entry (copy-tree org-blank-before-new-entry))) (when (org-at-heading-p) ...


5

You need (interactive "P") (not "p") to get a raw prefix argument (i.e. the ability to distinguish between C-u and C-u 4). See C-h f interactive. The raw prefix argument for C-- is not (-1), but -. See C-h i g (elisp) Prefix Command Arguments. open-line takes a required argument. (defun advanced-return (&optional arg) (interactive "P") (if (equal ...


4

As this happened with Python likewise, solution at python-mode.el, https://launchpad.net/python-mode, is to connect to process directly, not via comint-mode. Relies on start-process and process-send-string For example see functions py--start-fast-process and py--fast-send-string-intern


3

As Tom said, putting a display property on the newlines will kind of work. The problem is to figure out which lines to wrap. Here is an example to get you started: (let ((eol-regexp "[[:graph:]] ?\\(\n\\)[^\t\n ]")) (font-lock-add-keywords nil `((,eol-regexp 1 '(face default display " "))))) (visual-line-mode 1) This will "remove" newlines if it ...


3

The linebreaks are missing because there is a conflict between your coding system on the desktop and your emacs setup. Emacs can be configured to have different coding systems for the terminal, keyboard and clipboard. Try to set your clipboard coding system and selection coding system to utf-16-le, i.e.,: (if (eq system-type 'windows-nt) (progn (...


3

You need to add (package-initialize t) at the beginning of your ~/emacs. IIRC Emacs-25 will tend to do that for you, but it's even better to do it manually. The problem is simply that adaptive-wrap-mode is not defined until the ELPA packages have been initialized. If your ~/.emacs file doesn't initialize the ELPA packages with package-initialize, Emacs ...


2

One way of improving this that I have used (at times) for several years is to display sentences with line breaks as flowing after each other by folding the line breaks using the facilities of tex-fold (a part of AUCTeX). This means that this Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris pellentesque fringilla justo, quis dapibus velit ...


2

In my Emacs setup I have a mode with custom fontification, i.e. where I set font-lock-defaults. A single page down would use 30 seconds to display part of 30000 character line. This slow down was fixed by reducing regexp backtracking. Instead of: (".* ended with an incomplete command*" 0 font-lock-comment-face) do this ("^.\{1,80\} ended with an ...


2

It has not been removed (yet). It has been marked obsolete, which among other things implies that it is not autoloaded any more. (require 'longlines) (longlines-mode 1) still works as before.


2

You can do that by setting display margins. The following code is an attempt at that: (defun my/change-window-width (width) "Adjust margins so that window is centered" (interactive "NWindow width: ") (if (= 0 width) (set-window-margins nil 0 0) (let* ((cur-width (window-width)) (cur-m (window-margins)) (cur-l (if (and ...


2

I'm using eww, and needed line wrapping. First I tried line truncation, but that cut through the middle of words. visual-line-mode seems to provide intelligent line-wrapping on whitespace in the most straightforward way, and I'd be interested to know if that doesn't work for your reader.


Only top voted, non community-wiki answers of a minimum length are eligible