Emacs - Remove line number from mode-line - emacs

I already have line-numbers on the side so having the line-number in the mode-line is redundant. How do I get rid of it?

See the emacs wiki on mode lines.
You'd toggle this on or off by adding a line to your .emacs file:
(line-number-mode 0)
or (to enable):
(line-number-mode 1)

Related

Emacs whitespace mode change color of the text

In emacs 25.3, I enable 'whitespace' mode, it changes the color of the text.
See this example, the 2nd line, 'private' is now grey.
Can you please tell me how can I fix this?
It looks like you have an overly long line. You probably want to do one of:
remove lines from whitespace-style
modify whitespace-line face
increase whitespace-line-column
Get more help with C-h v whitespace-style and M-x customize-group whitespace
For reference, my whitespace config is just:
(setq whitespace-style '(newline space-mark tab-mark newline-mark))

Disabling a global mode (whitespace-style/mode) temporarily in a buffer

I have the following in my .emacs.d/init.el file:
;; Highlight lines longer than 100 characters
(setq whitespace-line-column 100)
(setq whitespace-style '(face lines-tail trailing))
(global-whitespace-mode 1)
This basically highlights characters that are exceeding 100 characters in a line. I would like to disable that temporarily in some buffers. I've tried M-x set-variable and to set the style or increasing the line column, but that doesn't take effect. I also tried disabling the global-white-space-mode but no luck.
Any ideas how I can do that?
Both whites-space-mode and global-whitespace-mode are toggles. Bind either or both to keys, for convenience, if you want. Repeat global-whitespace-mode to turn it off everywhere. Or use whitespace-mode (twice) to toggle it off in just the current buffer.

Emacs Whitespace Mode ignores whitespace-line-column and fill-column

I have an issue using Emacs 24.1.1 on Mac OS X. I'm editing Jade and CoffeeScript files, so I've turned on whitespace-mode for those file types.
What I'm seeing is that lines longer than 70 characters are highlighted with the whitespace-line font face, regardless of the setting of whitespace-line-column.
In this shot, it is clear that I've customized whitespace-line-column to track fill-column, and I've set fill-column to 120, but much shorter lines are being highlighted.
I've glanced over the code for the Jade mode and don't see anything that would explain the behavior, but I have only a passing understanding of Emacs Lisp.
Thanks in advance for any pointers!
You have to set whitespace-line-column before you activate whitespace-mode. That is, if you want to change its value it does not take effect unless you turn whitespace-mode off and on again. Ironically, that variable is not available for M-x customize until you have activated the mode once :-(
However, you can customize the global value of this variable by putting the following line in your .emacs file:
(setq whitespace-line-column 120)
Since your .emacs is evaluated when you start Emacs, the setting will take effect before you invoke whitespace-mode for the first time and should thus do what you want. If you don't want to set the value globally, but only for Jade files, put the following in your .emacs file instead:
(set (make-local-variable 'whitespace-line-column) 80)
(add-hook 'after-change-major-mode-hook
'(lambda () (when (eq major-mode 'jade-mode)
(setq whitespace-line-column 120))))
If you never want long lines to be highlighted specially at all, there is a third option you might want to consider. You could customize the variable whitespace-style (by typing M-x customize-variable ENTER whitespace-style ENTER) and in the value list remove the entries:
lines
lines-tail
(if any). This should turn off highlighting of long lines globally independent of the value of whitespace-line-column (again, only after you de- and re-activate whitespace mode).

How can I enable line wrap on word boundaries only in Emacs?

How do I configure Emacs so that line wrapping does not break in the middle of a word?
If you want to emulate the behavior of an editor like Notepad, you might want to turn on visual line mode. While setting word-wrap will cause line wrapping at word boundaries, any action you take on a line (e.g., moving up/down or killing) will still respect the newline character. Visual line mode will treat each display line as though it had a newline at the end.
(visual-line-mode t)
Line to add in .emacs file:
(global-visual-line-mode t)
M-x toggle-truncate-lines disable allows you to disable visually line breaking.
M-x auto-fill-mode + M-q allows you to word wrap for real a pre-existing paragraph.
Add this to your init file:
(setq-default word-wrap t)
Alternatively, press C-h vword-wrap in Emacs and follow the "customize" link near the end.
I discovered longlines-mode only recently (I think I was spelunking through the Emacs Info documentation). It wraps as you would expect in other UI editors' word-wrap feature. It's especially useful when I'm reading or writing free text with no newlines (a la Microsoft Word) without the ugly mid-word wrapping that happens when you use M-x toggle-word-wrap.
See LongLines.
My configuration:
(setq longlines-wrap-follows-window-size t)
(global-set-key [(control meta l)] 'longlines-mode)

How do I enable line numbers (on the left) every time I open Emacs?

I enable them by pressing: M-x linum-mode. How can I "translate" that into my.emacs file in order to enable it automatically every time I open EMACS?
Drop (global-linum-mode t) into your .emacs if you want it for every buffer. Otherwise, you can add a function to the appropriate hook of modes you're interested in to enable it for just that mode.
You should really read though the manual like I suggested in the last question of yours that I answered. ;)
Since Emacs 26, the new way is to use (global-) display-line-numbers-mode:
(global-display-line-numbers-mode 1)
One more solution is to use a linum-mode
linum-mode works fast on large files, so in order to enable it for your mode put this into your configuration:
(add-hook 'js2-mode-hook
(lambda ()
(linum-mode 1)))
linum-mode is a part of Emacs after version 22
More documentation about this mode is here
You can also put (line-number-mode 1) into your .emacs file. This way you can also have it be mode specific:
(defun my-c-mode-common-hook ()
(line-number-mode 1))
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
That way, it will only put the line numbers in if it's a C/C++ file.
You might want to consider this code in your .emacs file:
;; always show line numbers
(global-linum-mode 1)
;; insert a space if running in text mode
(if window-system
(progn)
(setq linum-format "%d ")
)
It adds a space between the line number and the editable lines in text mode, as it is done in graphics mode.