Function: find-file-other-window

find-file-other-window is an interactive and byte-compiled function defined in files.el.gz.

Signature

(find-file-other-window FILENAME &optional WILDCARDS)

Documentation

Edit file FILENAME, in another window.

Like C-x C-f (find-file) (which see), but creates a new window or reuses an existing one. See the function display-buffer.

Interactively, the default if you just type RET is the current directory, but the visited file name is available through the minibuffer history: type M-n (next-history-element) to pull it into the minibuffer.

The first time M-n (next-history-element) is used after Emacs prompts for the file name, the result is affected by file-name-at-point-functions, which by default try to guess the file name by looking at point in the current buffer. Customize the value of file-name-at-point-functions or set it to nil, if you want only the visited file name and the current directory to be available on first M-n (next-history-element) request.

Interactively, or if WILDCARDS is non-nil in a call from Lisp, expand wildcards (if any) and visit multiple files.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/files.el.gz
(defun find-file-other-window (filename &optional wildcards)
  "Edit file FILENAME, in another window.

Like \\[find-file] (which see), but creates a new window or reuses
an existing one.  See the function `display-buffer'.

\\<minibuffer-local-map>\
Interactively, the default if you just type RET is the current directory,
but the visited file name is available through the minibuffer history:
type \\[next-history-element] to pull it into the minibuffer.

The first time \\[next-history-element] is used after Emacs prompts for
the file name, the result is affected by `file-name-at-point-functions',
which by default try to guess the file name by looking at point in the
current buffer.  Customize the value of `file-name-at-point-functions'
or set it to nil, if you want only the visited file name and the
current directory to be available on first \\[next-history-element]
request.

Interactively, or if WILDCARDS is non-nil in a call from Lisp,
expand wildcards (if any) and visit multiple files."
  (interactive
   (find-file-read-args "Find file in other window: "
                        (confirm-nonexistent-file-or-buffer)))
  (let ((value (find-file-noselect filename nil nil wildcards)))
    (if (listp value)
	(progn
	  (setq value (nreverse value))
	  (switch-to-buffer-other-window (car value))
	  (mapc 'switch-to-buffer (cdr value))
	  value)
      (switch-to-buffer-other-window value))))