0

I would like to be able to move the cursor around using the visual buffer, but I don't want to add line breaks to the source file. I'm not sure a better way to describe it, so I got some gif examples.

Here is vscode: vscode

Here is emacs: emacs

Both have the same file open and I am moving around the same line of text, vscode treats the wrapped line as multiple while emacs treats it as a single. I would like to make emacs behave like vscode. I have spacemacs installed with the base setup and vim mode.

  • 1
    See visual-line-mode in the Emacs manual. – NickD Jun 25 at 4:14
  • @NickD I have that mode enabled already, is there some config that would allow me to use the arrow keys to move around using the visual lines? – GammaGames Jun 25 at 5:18
  • I tried (setq line-move-visual t) but it didn't change anything – GammaGames Jun 25 at 5:37
  • 1
    Provided you're using Emacs 23+, line-move-visual is what you're looking for, and it's enabled by default. Try with emacs -Q. If it's not working, and you're using Emacs 23 or later, then tell us what commands you're using to move up and down between lines. – phils Jun 25 at 11:15
  • 1
    Very good. I think you could go ahead and write your own answer to the question at this point. – phils Jun 25 at 15:19
0

I finally got it working. Emacs has the line-move-visual variable, but spacemacs requires spacemacs/toggle-visual-line-navigation to be run instead. If you want this command to modify the bindings for the arrow keys you'll have to switch spacemacs to the develop branch (as of 2020-06-25). To do this, skip to step 6 below.

If that solves your problem, congratulations! I am still running elementary Hera (based on Ubuntu 18.04) and was having issues with the elpa gpg key being expired. My workaround is to install emacs26, my full process to fix the issues follows.

  1. Remove and purge emacs: sudo apt remove --purge emacs
  2. Remove config: rm ~/.spacemacs && sudo rm -R ~/.emacs.d/
  3. Add emacs stable release PPA: sudo add-apt-repository ppa:kelleyk/emacs
  4. Install emacs: sudo apt install emacs26
  5. Install spacemacs: git clone https://github.com/syl20bnr/spacemacs ~/.emacs.d
  6. Change emacs to develop branch: cd ~/.emacs.d/ && git checkout develop
  7. Start emacs: emacs26
  8. Turn on visual line navigation spacemacs/toggle-visual-line-navigation-on

Voilà, visual line navigation with arrow keys on Ubuntu 18.04.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.