LoginSignup
5
3

More than 5 years have passed since last update.

Emacs で `|>` を楽に入力する

Last updated at Posted at 2016-03-08

Elixir を書いていて関数をパイプ記号 (|>) でつなげていくのは快感ですが、記号の入力は苦痛です。パイプ記号 | はなんかキーボードの端っこの方にあるし、> とも遠いしで。

で、こうすりゃいいんじゃないかとやってみたら快適でした。M-J を押すと改行して |> を入れるだけです。行の途中からでも大丈夫です。

もっと早くにやっておけばよかった。同案多数かもしれませんが置いときます。

~/.emacs.d/init.el
(eval-after-load "elixir-mode"
  #'(progn
      ;; 改行して行頭に |> をつける
      (defun my-elixir-newline-and-insert-pipe ()
        (interactive)
        (move-end-of-line 1)
        (newline-and-indent)
        (insert "|> "))
      (define-key elixir-mode-map (kbd "M-J") 'my-elixir-newline-and-insert-pipe)))
5
3
3

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
5
3