Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

20
21

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 5 years have passed since last update.

分割したウィンドウの大きさを変更する

Posted at

いままでノートPCで開発をしていた時は画面も小さかったのであまりバッファは分割していませんでした。最近広いモニタにしてバッファを分割することが多くなり、分割バッファの幅を変えるのにC-x {C-x }でやっており結構面倒でした。

ネットで調べていいのがあったのでその設定をメモしておきます。

設定ファイルに下記を追加します。

.emacs.d/init.el
(defun window-resizer ()
  "Control window size and position."
  (interactive)
  (let ((window-obj (selected-window))
        (current-width (window-width))
        (current-height (window-height))
        (dx (if (= (nth 0 (window-edges)) 0) 1
              -1))
        (dy (if (= (nth 1 (window-edges)) 0) 1
              -1))
        action c)
    (catch 'end-flag
      (while t
        (setq action
              (read-key-sequence-vector (format "size[%dx%d]"
                                                (window-width)
                                                (window-height))))
        (setq c (aref action 0))
        (cond ((= c ?l)
               (enlarge-window-horizontally dx))
              ((= c ?h)
               (shrink-window-horizontally dx))
              ((= c ?j)
               (enlarge-window dy))
              ((= c ?k)
               (shrink-window dy))
              ;; otherwise
              (t
               (let ((last-command-char (aref action 0))
                     (command (key-binding action)))
                 (when command
                   (call-interactively command)))
               (message "Quit")
               (throw 'end-flag t)))))))
(global-set-key "\C-c\C-r" 'window-resizer)

これで、Emacsを再起動し、分割されたバッファでC-c C-rをして、hを押すと境界線が左に、jを押すと下に、kを押すと上に、lを押すと右に移動します。

これは直感的でわかりやすいです。

参考URL

http://d.hatena.ne.jp/mooz/20100119/p1
http://d.hatena.ne.jp/khiker/20100119/window_resize

20
21
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

Qiita Advent Calendar is held!

Qiita Advent Calendar is an article posting event where you post articles by filling a calendar 🎅

Some calendars come with gifts and some gifts are drawn from all calendars 👀

Please tie the article to your calendar and let's enjoy Christmas together!

20
21

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?