0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Spacemacsで79文字目がどこなのか目印を表示させる

Last updated at Posted at 2020-10-08

PythonのPEP8 - Maximum Line Lengthのように、79文字を超えて入力したくないから79文字目に目印がほしい、となることがある。

.pyファイルを開いた時だけ目印を出すようにしてみる。


Emacsが26の場合は fci-modeを使う。ちょうど79文字目の列に線が引かれて、わかりやすくなる

.spacemacs(抜粋)
(defun dotspacemacs/user-config ()
  (add-hook 'python-mode-hook
            (lambda ()
              ;; 79文字制限の表示
              (setq-default fill-column 79)
              (fci-mode 1)))
)

Emacsが27の場合は display-fill-column-indicatorを使う ( fci-modeが使えなかった :innocent: )

cf. new display-fill-column-indicator-mode in emacs 27

.spacemacs(抜粋)
(defun dotspacemacs/user-config ()
  (add-hook 'python-mode-hook
            (lambda ()
              ;; 79文字制限の表示
              (setq-default display-fill-column-indicator-column 79)
              (setq-default display-fill-column-indicator-character ?\N{U+007C})
              (setq display-fill-column-indicator t)))
)

display-fill-column-indicator-character (目印に使う文字)の指定がまさかの文字コードなのでナニコレ感しかない。
たとえばUnicodeで |を使う場合は U+007C

cf. Using fill-column-indicator for Characters Per Line limit

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?