Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user

How to toggle whitespace mode in evil insert state?

I'd like to disable whitespace-mode while in insert mode, theevil insert state. The following hooks work, but require refreshing all font colors with (font-lock-fontify-buffer), and even then- sometimes it fails to refresh properly to show trailing whitespace.

While this example uses evil-mode, similar logic applies to any other hook.

(defun i42/enter-insert-mode ()
  (whitespace-mode -1)
  (font-lock-fontify-buffer))
(defun i42/exit-insert-mode ()
  (whitespace-mode 1)
  (font-lock-fontify-buffer))
(add-hook 'evil-insert-state-entry-hook 'i42/enter-insert-mode)
(add-hook 'evil-insert-state-exit-hook  'i42/exit-insert-mode)

Is there a better way to toggle white space mode?

How to toggle whitespace mode?

I'd like to disable whitespace-mode while in insert mode, the following hooks work, but require refreshing all font colors with (font-lock-fontify-buffer), and even then- sometimes it fails to refresh properly to show trailing whitespace.

While this example uses evil-mode, similar logic applies to any other hook.

(defun i42/enter-insert-mode ()
  (whitespace-mode -1)
  (font-lock-fontify-buffer))
(defun i42/exit-insert-mode ()
  (whitespace-mode 1)
  (font-lock-fontify-buffer))
(add-hook 'evil-insert-state-entry-hook 'i42/enter-insert-mode)
(add-hook 'evil-insert-state-exit-hook  'i42/exit-insert-mode)

Is there a better way to toggle white space mode?

How to toggle whitespace mode in evil insert state?

I'd like to disable whitespace-mode while in evil insert state. The following hooks work, but require refreshing all font colors with (font-lock-fontify-buffer), and even then- sometimes it fails to refresh properly to show trailing whitespace.

While this example uses evil-mode, similar logic applies to any other hook.

(defun i42/enter-insert-mode ()
  (whitespace-mode -1)
  (font-lock-fontify-buffer))
(defun i42/exit-insert-mode ()
  (whitespace-mode 1)
  (font-lock-fontify-buffer))
(add-hook 'evil-insert-state-entry-hook 'i42/enter-insert-mode)
(add-hook 'evil-insert-state-exit-hook  'i42/exit-insert-mode)

Is there a better way to toggle white space mode?

added 79 characters in body
Source Link
ideasman42
  • 9.2k
  • 1
  • 35
  • 123

I'd like to disable whitespace-mode while in insert mode, the following hooks work, but require refreshing all font colors with (font-lock-fontify-buffer), and even then- sometimes it fails to refresh properly to show trailing whitespace.

While this example uses evil-mode, similar logic applies to any other hook.

(defun i42/enter-insert-mode ()
  (whitespace-mode -1)
  (font-lock-fontify-buffer))
(defun i42/exit-insert-mode ()
  (whitespace-mode 1)
  (font-lock-fontify-buffer))
(add-hook 'evil-insert-state-entry-hook 'i42/enter-insert-mode)
(add-hook 'evil-insert-state-exit-hook  'i42/exit-insert-mode)

Is there a better way to toggle white space mode?

I'd like to disable whitespace-mode while in insert mode, the following hooks work, but require refreshing all font colors with (font-lock-fontify-buffer), and even then- sometimes it fails to refresh properly to show trailing whitespace.

(defun i42/enter-insert-mode ()
  (whitespace-mode -1)
  (font-lock-fontify-buffer))
(defun i42/exit-insert-mode ()
  (whitespace-mode 1)
  (font-lock-fontify-buffer))
(add-hook 'evil-insert-state-entry-hook 'i42/enter-insert-mode)
(add-hook 'evil-insert-state-exit-hook  'i42/exit-insert-mode)

Is there a better way to toggle white space mode?

I'd like to disable whitespace-mode while in insert mode, the following hooks work, but require refreshing all font colors with (font-lock-fontify-buffer), and even then- sometimes it fails to refresh properly to show trailing whitespace.

While this example uses evil-mode, similar logic applies to any other hook.

(defun i42/enter-insert-mode ()
  (whitespace-mode -1)
  (font-lock-fontify-buffer))
(defun i42/exit-insert-mode ()
  (whitespace-mode 1)
  (font-lock-fontify-buffer))
(add-hook 'evil-insert-state-entry-hook 'i42/enter-insert-mode)
(add-hook 'evil-insert-state-exit-hook  'i42/exit-insert-mode)

Is there a better way to toggle white space mode?

edited tags
Link
lawlist
  • 19.5k
  • 5
  • 42
  • 125
Source Link
ideasman42
  • 9.2k
  • 1
  • 35
  • 123
Loading