aboutsummaryrefslogtreecommitdiffstats
path: root/doc/qtcreator/src/editors/creator-only/creator-diff-editor.qdoc
blob: de83a3e1ab76498dc64509159e8fef62925152c8 (plain)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Copyright (C) 2024 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only

// **********************************************************************
// NOTE: the sections are not ordered by their logical order to avoid
// reshuffling the file each time the index order changes (i.e., often).
// Run the fixnavi.pl script to adjust the links to the index order.
// **********************************************************************

/*!
    \page creator-diff-editor.html
    \previouspage creator-how-tos.html

    \ingroup creator-how-to-edit

    \title Compare files

    You can view unsaved changes in the current file or all open files,
    as well as compare any two text files. They can be either versions of
    the same file or arbitrary files.

    \section1 View unsaved changes

    To view unsaved changes in the current file, go to \uicontrol Tools >
    \uicontrol Diff > \uicontrol {Diff Current File}.

    To view unsaved changes in all open files, go to \uicontrol Tools >
    \uicontrol Diff > \uicontrol {Diff Open Files}.

    \section1 Compare two files

    To compare two files:

    \list 1

        \li Go to \uicontrol Tools > \uicontrol Diff >
            \uicontrol {Diff External Files}.

        \li Select two files to compare.

    \endlist

    To compare the currently opened file against another file in a project
    or the file system:

    \list 1

        \li Open the first file in an editor.

        \li Right-click the second file in the \uicontrol Projects
            or \uicontrol {File System} view and select
            \uicontrol {Diff Against Current File}.

    \endlist

    If \QC cannot detect the encoding of the files to compare, an info bar
    displays the option to reload the document using some other
    encoding. For more information, see \l {Change text encoding}.

    \section1 View changes

    \image creator-diff-editor.png {Diff editor output in the Edit mode}

    View the changes in the \uicontrol Edit mode. Color coding is
    used to mark changed lines. By default, red indicates lines that contain
    removed text (painted another shade of red) in the left pane and green
    indicates lines that contain added text (painted another shade of green)
    in the right pane.

    To view the differences in a unified view where changed rows are placed
    below each other, select \inlineimage icons/unifieddiff.png
    (\uicontrol {Switch to Unified Diff Editor}).

    To switch back to the side-by-side view, select
    \inlineimage icons/sidebysidediff.png
    (\uicontrol {Switch to Side by Side Diff Editor}).

    To only show text changes, select \uicontrol {Ignore Whitespace}.

    To expand the context for the changes, set the number of unchanged lines to
    show in \uicontrol {Context lines}.

    By default, the horizontal scroll bars in the left and right pane are
    synchronized. To use them independently of each other, select
    \inlineimage icons/linkicon.png
    (\uicontrol {Synchronize Horizontal Scroll Bars}).

    \section1 Revert and apply changes

    To revert the changes, right-click added text and then select
    \uicontrol {Revert Chunk} in the context menu.

    To apply the changes, select removed text and then select
    \uicontrol {Apply Chunk}.

    \section1 Reload files

    If the files change outside \QC, select \inlineimage icons/reload_gray.png
    (\uicontrol {Reload Editor}) to compare them again and to show the results.

    \if defined(qtcreator)
    \section1 Paste changes for review

    To send a chunk of changes to a \l{Pasting and Fetching Code Snippets}
    {code pasting service}, select \uicontrol {Send Chunk to CodePaster} in the
    context menu.
    \endif

    \section1 Change colors

    To change the default colors, go to \preferences >
    \uicontrol {Text Editor} > \uicontrol {Font & Colors}. Create your own color
    scheme and select new colors for the following items:

    \list

        \li \uicontrol {Diff File Line} sets the color of the line that shows
            the path and filename of the changed file.

        \li \uicontrol {Diff Context Line} sets the color of the line that
            shows the number of hidden lines between changed lines.

        \li \uicontrol {Diff Source Line} sets the color of lines that contain
            removed text.

        \li \uicontrol {Diff Source Character} sets the color that indicates
            removed characters.

        \li \uicontrol {Diff Destination Line} sets the color of lines that
            contain added text.

        \li \uicontrol {Diff Destination Character} sets the color that
            indicates added characters.

    \endlist
*/