Function: vi-put-before

vi-put-before is an interactive and byte-compiled function defined in vi.el.gz.

Signature

(vi-put-before ARG &optional AFTER-P)

Documentation

Put yanked (in vi sense) text back before/above cursor.

If a numeric prefix value (currently it should be >1) is given, put back text as lines. If the optional after-p is given, put after/below the cursor.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/obsolete/vi.el.gz
(defun vi-put-before (arg &optional after-p)
  "Put yanked (in vi sense) text back before/above cursor.
If a numeric prefix value (currently it should be >1) is given, put back
text as lines.  If the optional after-p is given, put after/below the cursor."
  (interactive "P")
  (let ((reg (vi-prefix-char-value arg)) put-text)
    (if (and reg (or (< reg ?1) (> reg ?9)) (null (get-register reg)))
	(error "Nothing in register %c" reg)
      (if (null reg) (setq reg ?1))	; the default is the last text killed
      (setq put-text
	    (cond
	     ((and (>= reg ?1) (<= reg ?9))
	      (setq this-command 'yank) ; So we may yank-pop !!
	      (current-kill (- reg ?0 1) 'do-not-rotate))
	     ((stringp (get-register reg)) (get-register reg))
	     (t (error "Register %c is not containing text string" reg))))
      (if (vi-string-end-with-nl-p put-text) ; put back text as lines
	  (if after-p
	      (progn (forward-line 1) (beginning-of-line))
	    (beginning-of-line))
	(if after-p (forward-char 1)))
      (push-mark)
      (insert put-text)
      (exchange-point-and-mark)
;;    (back-to-indentation)      ; this is not allowed if we allow yank-pop
      (vi-set-last-change-command 'vi-put-before arg after-p))))