ファイルを開くときに使用できます。
$ emacs +2:9 practice.b
これにより、「practice.b」ファイルの行2とその行の文字9が開きます。すでに実行しているEmacsでこれをジャンプするにはどうすればよいですか?わかりました。M-x goto-line
しかし、セミコロンを認識しません。
ベストアンサー1
M-x goto-line
(M-g g
またはM-g M-g
)を使用すると、ターゲット行の先頭に移動します。その後、M-g | 8 RET
(M-x move-to-column 8 RET
)を使用してターゲット列に移動できます(C-u 8 right
ワイド文字がない場合は機能します)。 Emacsは0から始まる列の番号を付けますが、コマンドラインオプションは+LINE:COLUMN
1から始まる列の番号を付けるため、列8になります。
入力できるEmacsコマンドが必要な場合は、次の2:9
コードのいくつかをファイルに貼り付けて引数.emacs
として書き込むことができますgoto-line
。このコードはEmacs 23でのみ最小限にテストされています。
(defadvice goto-line (around goto-column activate)
"Allow a specification of LINE:COLUMN instead of just COLUMN.
Just :COLUMN moves to the specified column on the current line.
Just LINE: moves to the current column on the specified line.
LINE alone still moves to the beginning of the specified line (like LINE:0)."
(if (symbolp line) (setq line (symbol-name line)))
(let ((column (save-match-data
(if (and (stringp line)
(string-match "\\`\\([0-9]*\\):\\([0-9]*\\)\\'" line))
(prog1
(match-string 2 line)
(setq line (match-string 1 line)))
nil))))
(if (stringp column)
(setq column (if (= (length column) 0)
(current-column)
(string-to-int column))))
(if (stringp line)
(setq line (if (= (length line) 0)
(if buffer
(save-excursion
(set-buffer buffer)
(line-number-at-pos))
nil)
(string-to-int line))))
(if line
ad-do-it)
(if column
(let ((limit (- (save-excursion (forward-line 1) (point))
(point))))
(when (< column limit)
(move-to-column column))))))