Function: viper-change-state-to-vi

viper-change-state-to-vi is an interactive and byte-compiled function defined in viper-cmd.el.gz.

Signature

(viper-change-state-to-vi &rest _)

Documentation

Change Viper state to Vi.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emulation/viper-cmd.el.gz
;; This also takes care of the annoying incomplete lines in files.
;; Also, this fixes `undo' to work vi-style for complex commands.
(defun viper-change-state-to-vi (&rest _)
  "Change Viper state to Vi."
  (interactive)
  (if (and viper-first-time (not (viper-is-in-minibuffer)))
      (viper-mode)
    (if overwrite-mode (overwrite-mode -1))
    (or (overlayp viper-replace-overlay)
      (viper-set-replace-overlay (point-min) (point-min)))
    (viper-hide-replace-overlay)
    ;; Expand abbrevs iff the previous character has word syntax.
    (and abbrev-mode
	 (eq (char-syntax (preceding-char)) ?w)
	 (expand-abbrev))
    (if (and auto-fill-function (> (current-column) fill-column))
	(funcall auto-fill-function))
    ;; don't leave whitespace lines around
    (if (and (memq last-command
		   '(viper-autoindent
		     viper-open-line viper-Open-line
		     viper-replace-state-exit-cmd))
	     (viper-over-whitespace-line))
	(indent-to-left-margin))
    (viper-add-newline-at-eob-if-necessary)
    (viper-adjust-undo)

    (if (eq viper-current-state 'emacs-state)
	(viper-restore-cursor-color 'after-emacs-mode)
      (viper-restore-cursor-color 'after-insert-mode))

    (viper-change-state 'vi-state)

    ;; Protect against user errors in hooks
    (condition-case conds
	(run-hooks 'viper-vi-state-hook)
      (error
       (viper-message-conditions conds)))))