I know that you can toggle line numbers with the key combination SPC + t + l but it changes back to absolute line numbers when restarting Doom Emacs. How can I configure Doom Emacs to set relative line numbers every time I start emacs?
As of commit a7da9a4 doom-line-numbers-style has been removed. The correct way of setting line number type is to set the display-line-numbers-type variable. This is part of Emacs itself and as such will work outside of doom too.
To answer op's question, the way to set line numbering to be relative is to add the following snippet to your configuration file which in the case of doom is ~/.doom.d/config.el.
(setq display-line-numbers-type 'relative)
Assuming on latest version, which is v2.0.9 at the time of writing, the preferred way would be to set the doom-line-numbers-style to 'relative in your own private config. Simply add (setq doom-line-numbers-style 'relative) to that config. This will configure emacs to start with relative line numbering.
Note however that toggling line numbers with SPC t l will still change it back to absolute line numbering. To toggle relative line numbering, you need to provide a universal argument to the toggle command. In this case, you'd have to do SPC u SPC t l. The SPC u there stands for the universal/prefix argument.
Related
In the case of vim it is possible to set it as follows.
set whichwrap+=<,>,[,]
How can I set it for Spacemacs(vim editing style)?
It is not a Spacemacs-specific "issue", it comes from the included evil-mode Emacs package.
Short answer:
(setq evil-cross-lines t)
... before evil-mode is loaded.
In .spacemacs, this can be under dotspacemacs/user-init
Long answer:
Pressing Ctrl-h k followed by l or h shows you what commands are bound to these keys, and (in recent emacs versions), the keymap in which they are defined. The commands (or rather, motions) are evil-forward-char and evil-backward-char, respectively. Looking at their definition, in evil-commands.el, it can be seen that their movement is restricted to the current line - or not - based on the value of the variable evil-cross-lines, which is by default nil. And the docstring of this variable confirms it: "Whether motions may cross newlines".
How do I get hybrid line numbering (relative line numbers, but the current line shows the absolute line number instead of 0) in spacemacs for all files?
I tried setting relative line numbers in user-config but that doesn't seem to be working, and can't figure out how to replace the 0 in relative mode either:
(global-linum-mode)
(setq-default dotspacemacs-line-numbers 'relative)
The dotspacemacs-line-numbers variable already exists in your .spacemacs, in the dotspacemacs/init function. If it is not the case you can update your .spacemacs to the last template with the help of SPC f e D.
Change its value to 'relative, as in:
;; If non nil line numbers are turned on in all `prog-mode' and `text-mode'
;; derivatives. If set to `relative', also turns on relative line numbers.
;; (default nil)
dotspacemacs-line-numbers 'relative
Then remove the two lines you added in your dotspacemacs/user-config. All you need is to change the variable as explained above, it will take care of applying the changes for you :-)
I like to run my editor full-screen. The only thing is, though, that when I do this, the word wrap only kicks in when the line hits the right edge of the screen. I would like it to do so, already when the line hits, say, column number 200.
How do I do that?
I would like it to happen in all modes, e.g., Org-mode. I added the line (global-visual-line-mode t) to my .emacs file, in order for the word wrapping also to work in org-mode.
I'm running Emacs 23.
I got it working! Here is what I added to my .emacs file to make it happen:
(add-hook 'text-mode-hook 'turn-on-auto-fill)
(add-hook 'text-mode-hook
'(lambda() (set-fill-column 80)))
Type M-x auto-fill-mode to activate automatic line-wrapping after a certain column. Then set the actual line width through the variable fill-column as described by user choroba (C-x f).
Note though that this works a bit differently from what other text editors do. M-q will re-format the current paragraph.
You can set the line width with C-xf (set-fill-column).
Afterwards, you might need to hit M-q to reformat the current paragraph (fill-paragraph), or select text to be justified and run fill-region.
The suggestion for turn-on-auto-fill will work if you want hard newlines in the files you're editing. If not, and you just want word-wrap, consider instead visual-fill-column-mode, which just does the normal word-wrap that would happen at the edge of the window, but at the specified fill-column.
See the Emacs manual (C-h r), node Filling. See in particular the first subnode in the menu, Auto Fill.
I'm using emacs and auctex to write LaTeX documents. For some reason, M-e doesn't move to the end of the sentence in tex-mode as it did when I went through the tutorial. It moves to the end of the paragraph. (That is, it moves to just before the next double line break)
What is wrong? Do I need to turn on/off some mode to skip to the next full stop? How do I check which modes are active?
I noticed that the same happens in my Emacs. The problem is that the variable sentence-end-double-space is set to t. This means that Emacs expects a sentence to end with a double space. By setting to nil things work properly, i.e., Emacs recognizes a period followed by a single space as the end of sentences.
The first thing to check is what M-e is bound to. In tex-mode, for me, it is bound to forward-sentence. You find this out by C-h k M-e.
It sounds as though it's bound to forward-paragraph, in which case I'd check your .emacs file to see if you've got any overrides in tex-mode hooks, or other things. You can also try running without your .emacs: emacs -q, and seeing what M-e is bound to (to determine if it truly is your .emacs). You can also start without the site lisp file emacs -q --no-site-file - in case your administrators have added anything.
In Emacs (23 on Mac Leopard), I've discovered how to highlight the current line with hl-line-mode, but when using it globally in all buffers, it highlights the current line in all buffers in all frames.
I'd like to be able to highlight the current line (or at least have a different face for it) in only the currently active buffer. I'm sure this must be possible to some degree as the cursor changes dependent on whether the buffer is the current one or not.
Thanks
Singletoned
Looking at the documentation for hl-line-mode, it appears that you might have the variable hl-line-sticky-flag turned on. Try
C-h v hl-line-sticky-flag
to see if it's non-nil, and if so, then add
(setq hl-line-sticky-flag nil)
to your .emacs.