aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/vi/docs/internals/autowrite
blob: 55cd13b8f72e2bfcdd2d6a36eaea3f86d2bd876a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#	@(#)autowrite	8.2 (Berkeley) 9/28/93

Vi autowrite behavior, the fields with *'s are "don't cares".

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Commands that are affected only by autowrite:

Command	File		Autowrite?	Action:
	modified?
-----------------------------------------------
^Z	Y		Y		Write file and suspend.
^Z	Y		N		Suspend.
^Z	N		*		Suspend.

# This behavior is NOT identical to :edit.
^	Y		Y		Write file and jump.
^	Y		N		Error.
^	N		*		Jump.

# The new nvi command ^T (:tagpop) behaves identically to ^].
# This behavior is identical to :tag, :tagpop, and :tagpush with
# force always set to N.
^]	Y		Y		Write file and jump.
^]	Y		N		Error.
^]	N		*		Jump.

# There's no way to specify a force flag to the '!' command.
:!	Y		Y		Write file and execute.
:!	Y		N		Warn (if warn option) and execute.
:!	N		*		Execute.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Commands that are affected by both autowrite and force:

NOTE: the "force" flag is never passed on, i.e. the write
to the file caused by the autowrite flag is never forced.

Command	File		Autowrite?	Force? 	Action:
	modified?			(!)
-------------------------------------------------------
# The first rule (YYY) is historic practice, but seems wrong.
# In nvi, :next and :prev commands behave identically to :rewind.
:next 	Y		Y		Y	Write changes and jump.
:next 	Y		Y		N	Write changes and jump.
:next 	Y		N		Y	Abandon changes and jump.
:next 	Y		N		N	Error.
:next 	N		*		*	Jump.

:rewind	Y		Y		Y	Abandon changes and jump.
:rewind	Y		Y		N	Write changes and jump.
:rewind	Y		N		Y	Abandon changes and jump.
:rewind	Y		N		N	Error.
:rewind	N		*		*	Jump.

# The new nvi commands, :tagpop and :tagtop, behave identically to :tag.
# Note, this behavior is the same as :rewind and friends, as well.
:tag	Y		Y		Y	Abandon changes and jump.
:tag	Y		Y		N	Write changes and jump.
:tag	Y		N		Y	Abandon changes and jump.
:tag	Y		N		N	Error.
:tag	N		*		*	Jump.

# The command :suspend behaves identically to :stop.
:stop	Y		Y		Y	Suspend.
:stop	Y		Y		N	Write changes and suspend.
:stop	Y		N		Y	Suspend.
:stop	Y		N		N	Suspend.
:stop	N		*		*	Suspend.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Commands that might be affected by autowrite, but aren't:

Command	File		Autowrite?	Force? 	Action:
	modified?			(!)
-------------------------------------------------------
#:ex, and :vi (executed while in vi mode) behave identically to :edit.
:edit 	Y		*		Y	Abandon changes and jump.
:edit 	Y		*		N	Error.
:edit 	N		*		*	Jump.

:quit	Y		*		Y	Quit.
:quit	Y		*		N	Error.
:quit	N		*		*	Quit.

:shell	*		*		*	Execute shell.

:xit	Y		*		*	Write changes and exit.
:xit	N		*		*	Exit.