Documentation of File Comparison And Merge

Opções da Linha de Comandos

Comparar 2 ficheiros:

kdiff3 ficheiro1 ficheiro2

Juntar 2 ficheiros:

kdiff3 file1 file2 -m
kdiff3 file1 file2 -o outputfile

Comparar 3 ficheiros:

kdiff3 ficheiro1 ficheiro2 ficheiro3

Juntar 3 ficheiros:

kdiff3 file1 file2 file3 -m
kdiff3 file1 file2 file3 -o outputfile

Repare que o ficheiro1 será tratado como base para o ficheiro2 e o ficheiro3.

Caso especial: Ficheiros com o mesmo nome
If all files have the same name but are in different directories, you can reduce typework by specifying the filename only for the first file. ⪚:

kdiff3 pasta1/ficheiro pasta2 pasta3

Linha de comandos para iniciar uma comparação ou junção de pastas:
É bastante semelhante, mas diz respeito agora apenas às pastas.

kdiff3 dir1 dir2
kdiff3 dir1 dir2 -o destdir
kdiff3 dir1 dir2 dir3
kdiff3 dir1 dir2 dir3 -o destdir

Para a comparação e junção de pastas, poderá continuar a ler aqui.

For more information on command line options use:

kdiff3 --help
Options:
  -m, --merge               Merge the input.
  -b, --base file           Explicit base file. For compatibility with certain tools.
  -o, --output file         Output file. Implies -m. E.g.: -o newfile.txt
  --out file                Output file, again. (For compatibility with certain tools.)
  --auto                    No GUI if all conflicts are auto-solvable. (Needs -o file)
  --qall                    Don't solve conflicts automatically. (For compatibility...)
  --L1 alias1               Visible name replacement for input file 1 (base).
  --L2 alias2               Visible name replacement for input file 2.
  --L3 alias3               Visible name replacement for input file 3.
  -L, --fname alias         Alternative visible name replacement. Supply this once for every input.
  -u                        Has no effect. For compatibility with certain tools.

Janela de Abertura
Dado que é necessário seleccionar vários ficheiros, o programa tem uma janela de abertura especial:
The open dialog allows to edit the filenames by hand, selecting a file via the file-browser (File...) or allows to choose recent files from the drop-down lists. If you open the dialog again, then the current names still remain there. The third input file is not required. If the entry for C remains empty, then only a two file diff analysis will be done.
You can also select a directory via Dir.... If for A a directory is specified then a directory-comparison/merge starts. If A specifies a file but B, C or the output specify a directory, then KDiff3 uses the filename from A in the specified directories.
If Merge is selected, then the Output line becomes editable. But it is not required to specify the output filename immediately. You can also postpone this until saving.
The Configure... button opens the options-dialog, so that you can set the options before running the analysis.

Colar e Arrastar Dados
Sometimes you want to compare parts of a text that is not an own file. KDiff3 also allows you to paste text from the clipboard into the diff input window that has the focus. The diff analysis happens immediately then. In the open dialog you need not specify files then, but just close it via Cancel.
O utilizador também poderá usar o 'drag and drop': Arraste um ficheiro de um gestor de ficheiros ou o texto seleccionado de um editor e arrastá-lo para uma janela de introdução de diferenças.
Qual é a ideia? Algumas vezes um ficheiro contém duas funções semelhantes, mas a verificação sobre as semelhanças entre elas é um grande esforço, se você precisar de criar primeiro dois ficheiros e depois carregá-los. Assim, poderá simplesmente copiar, colar e comparar as secções relevantes.
Currently you can't drag anything from KDiff3. Only dropping in the diff input is supported.
Some editors still interpret the drag and drop into another program like cut (instead of copy) and paste. Your original data might be lost then.

Interpreting The Information In The Input Windows
At the top of each text window is its info line. The info lines of the input windows contain a letter A, B or C, the filename and the line number of the first visible line in the window. (Note that window C is optional.) Each info line appears in a different color. (If the paths are too long to fit, then you can move the mouse onto the info line and a tooltip will show the complete name.)
The three input windows are assigned the letters A, B and C. A has color blue, B has green and C has magenta. (These are the defaults, but can be changed in the Settings menu.)
When a difference is detected then the color shows which input file differs. When both other input files differ then the color used to express this is red by default (Conflict color in the settings). This colorscheme is especially useful in the case of three input files, which will be seen in the next section (Merging).
Left of each text is the summary column. If differences occurred on a line then the summary column shows the respective color. For a white-space-only difference the summary is chequered. For programming languages where white space is not so important this is useful to see at one glance if anything of importance was modified. (In C/C++ white space is only interesting within strings, comments, for the preprocessor, and some only very esoteric situations.)
A linha vertical que separa a coluna do resumo e o texto é interrompida (tracejada), se o ficheiro de entrada não tiver aí nenhuma linha. Quando a mudança de linha estiver activa, então esta linha vertical aparece ponteada para as linhas repartidas.
On the right side a overview column is visible left of the vertical scrollbar. It shows the compressed summary column of input A. All the differences and conflicts are visible at one glance. When only two input windows are used, then all differences appear red here because every difference is also a conflict. A black rectangle frames the visible part of the inputs. For very long input files, when the number of input lines is bigger than the height of the overview column in pixels, then several input lines share one overview line. A conflict then has top priority over simple differences, which have priority over no change, so that no difference or conflict is lost here. By clicking into this overview column the corresponding text will be shown.

Juntar e a Janela do Editor do Resultado da Junção
The merge output editor window (below the diff input windows) also has an info line at the top showing Output:, the filename and [Modified] if you edited something. Usually it will contain some text through the automatic merge facilities, but often it will also contain conflicts.
Saving is disabled until all conflicts are resolved. (Use the Go to prev/next unsolved conflicts buttons to find the remaining conflicts.)
Com apenas dois ficheiros de entrada, todas as diferenças são também conflitos que necessitam de ser resolvidos manualmente.
Com três ficheiros de entrada, o primeiro ficheiro é tratado como a base, enquanto que o segundo e o terceiro contêm as modificações. Quando, em qualquer linha, só o ficheiro B ou o C tiverem sido alterados mas não ambos, então será seleccionada a origem alterada. Só quando o B e o C alteraram as mesmas linhas é que a ferramenta detecta um conflito que deverá ser resolvido manualmente. Quando o B e o C são iguais mas não são o mesmo que o A, é seleccionado o C.
The merge output editor window also has a summary column on the left. It shows the letter of the input from which a line was selected or nothing if all three sources where equal on a line. For conflicts it shows a questionmark ? and the line shows <Merge Conflict>, all in red. Because solving conflicts line by line would take very long, the lines are grouped into groups that have the same difference and conflict characteristics. But only-white-space-conflicts are separated from non-white-space-conflicts in order to ease the merging of files were the indentation changed for many lines.
When clicking into the summary column with the left mouse button in either window then the group belonging to that line will be selected in all windows and the beginning of that group will be shown. (This might involve an automatic position jump in the windows if the beginning of a group is not visible.) This group then becomes the current group. It is highlighted with the Current range (diff) background color and a black bar appears on the left side of the text.
Note the input selector buttons containing the letters A, B and C in the button bar below the menu bar. When clicking on either input selector button, the lines from that input will be added at the end of the selected group if that group didn't contain that source before. Otherwise the lines from that input will be removed.
Besides, you can directly edit any line. The summary column will show m for every line that was modified.
Sometimes, when a line is removed either by automatic merge or by editing and no other lines remain in that group, then the text <No src line> will appear in that line. This is just a placeholder for the group for when you might change your mind and select some source again. This text won't appear in the saved file or in any selections you want to copy and paste.
The text <Merge Conflict> will appear in the clipboard if you copy and paste some text containing such a line.
The normal merge will start by solving simple conflicts automatically. But the Merge menu provides some actions for other common needs. If you have to select the same source for most conflicts, then you can choose A, B or C everywhere, or only for the remaining unsolved conflicts, or for unsolved whitespace conflicts. If you want to decide every single delta yourself, you can Set deltas to conflicts. Or if you want to return to the automatic choices of KDiff3 then select Automatically solve simple conflicts. KDiff3 then restarts the merge. For actions that change your previous modifications KDiff3 will ask for your confirmation before proceeding.
When choosing either source for unsolved whitespace conflicts and the options Ignore Numbers or Ignore C/C++ Comments are used then changes in numbers or comments will be treated like whitespace too.

Navegação e Edição
Much navigation will be done with the scroll bars and the mouse but you can also navigate with the keys. If you click into either window then you can use the cursor buttons Left Arrow, Right Arrow, Up Arrow, Down Arrow, Page Up, Page Down, Home, End, Home, End as you would in other programs. The overview-column next to the vertical scroll bar of the input files can also be used for navigating by clicking into it.
You can also use a wheel mouse to scroll up and down.
In the merge output editor you can also use the other keys for editing. You can toggle between insert and overwrite mode with the Insert key. (Default is insert-mode.)
A click into any summary column will synchronise all windows to show the beginning of the same group of lines (as explained in section "Merging").
The button bar also contains seven navigation buttons with which you can jump to the current/first/last difference, to the next/previous difference (Down Arrow/Up Arrow), to the next/previous conflict (Page Down/Page Up), or to the next/previous unsolved conflict. Note that for KDiff3 a conflict that was not automatically solved at the start of the merge stays a conflict even if it is solved. Hence the necessity to distinguish unsolved conflicts.
There also is a button Automatically go to next unsolved conflict after source selection (Auto-Advance). If you enable this, then, when one source is selected, then KDiff3 will jump to and select the next unsolved conflict automatically. This can help when you always want to choose one source only. When you need both sources, or you want to edit after selecting, then you probably want to switch this off. Before proceeding to the next unsolved conflict KDiff3 shows you the effect of your choice for a short time. This delay is adjustable in the Diff & Merge Settings: You can specify the Auto-Advance delay in milli seconds between 0 and 2000.
Tired of many clicks? Use a small Auto-Advance-delay and the shortcuts 1, 2 and 3 to select files A, B or C for many conflicts.

Seleccionar, Copiar e Colar
The input windows don't show a cursor, so selections must be made with the mouse by clicking with the at the start, holding down the mousebutton and moving to the end, where you release the mouse button again. You can also select a word by double clicking it. In the merge output editor you can also select via the keyboard by holding the button and navigation with the cursor keys.
To copy to the clipboard you must press the Copy button (C or Insert). But there exists an option Auto Copy Selection. If this is enabled, then whatever you select is copied immediately and you don't need to explicitly copy. But pay attention when using this because the contents of the clipboard might then be destroyed accidentally.
Cut (X or Delete) copies to the clipboard and deletes the selected text and Paste (V or Insert) inserts the text in the clipboard at the cursor position or over the current selection.

Gravar
Saving will only be allowed, when all conflicts were solved. If the file already exists and the Backup files option is enabled then the existing file will be renamed with an .orig extension, but if such a file exists it will be deleted. When you exit or start another diff-analysis and data wasn't saved yet, then KDiff3 will ask if you want to Save, Cancel or Proceed without saving. KDiff3 does not catch any signals. So if you kill KDiff3 then your data will be lost.)
Line endings are saved according to the normal method on the underlying operating system. For Unices each line ends with an linefeed-character \n, while for based systems each line ends with a carriage-return + a linefeed \r\n. KDiff3 does not preserve the line-endings of the input files, which also means that you shouldn't use KDiff3 with binary files.

Procurar Sequências de Texto
You can search for a string in any text-window of KDiff3. The Find ... command (F) in the Edit menu opens a dialog that lets you specify the string to search for. You can also select the windows which should be searched. Searching will always start at the top. Use the Find Next command (F3) to proceed to the next occurence. If you select to search several windows then the first window will be searched from top to bottom before the search starts in the next window at the top again,

Opções
Options and the recent-file-list will be saved when you exit the program, and reloaded when you start it. (Menu Settings Configure KDiff3 ...)

Tipo de Letra
Seleccione um tipo de letra monoespaçado. (Em alguns sistemas, esta janela irá também apresentar os tipos de letra de tamanho variável, mas você não os deverá usar.)
Texto Itálico para os Deltas:	Se seleccionar isto, então as diferenças no texto serão escritas com a versão itálica do tipo de letra seleccionado. Se o tipo de letra não suportar caracteres itálicos, isto não fará nada.

Colors
Cor principal:	Normalmente preto.
Cor de fundo:	Normalmente branco.
Cor de Fundo das Diferenças:	Normalmente a cinzento claro.
Cor A:	Normalmente a azul escuro.
Cor B:	Normalmente a verde escuro.
Cor C:	Normalmente a magenta escuro.
Cor do Conflito:	Normalmente a vermelho.
Cor de fundo do intervalo actual:	Normalmente a amarelo claro.
Cor de fundo da diferença do intervalo actual:	Normalmente a amarelo escuro.
On systems with only 16 or 256 colors some colors are not available in pure form. On such systems the Defaults button will choose a pure color.

Configuração do Editor
O Tab insere espaços:	Se isto estiver desactivado e você carregar na tecla do tabulador, será inserido um carácter de tabulação, caso contrário serão inseridos os espaços com a quantidade apropriada.
Tamanho das tabulações:	Poderá ser ajustado de acordo com as suas necessidades específicas. Por omissão é igual a 8.
Indentação automática:	When pressing or Return the indentation of the previous line is used for the new line.
Copiar automaticamente a selecção:	Quando activo, qualquer selecção é posta automaticamente na área de transferência e não precisa de a copiar explicitamente.
Estilo de fim de linha:	Ao gravar, o utilizador poderá seleccionar o estilo do fim de linha que prefere.O valor por omissão é a escolha comum para o sistema operativo usado.
Use locale encoding:	For displaying foreign characters. Try changing this if some characters of your language aren't displayed correctly.

Diff & Merge Settings
Ao comparar os ficheiros, o KDiff3 tenta primeiro corresponder as linhas iguais em todos os ficheiros de entrada. Só durante este passo é que poderá ignorar os espaços em branco. O segundo passo compara cada uma das linhas. Neste passo, os espaços em branco não serão ignorados. Também durante a junção os espaços em branco não serão ignorados.
Manter o 'Carriage Return':	Some editors (on some systems) save carriage return \r and linefeed \n characters at the end of line, while others will only save the linefeed \n. Usually KDiff3 ignores the carriage return, but then files that don't have equal sizes, look equal in side by side comparison. When this option is on, then the carriage return characters are made visible but are treated as white space. This option must be off during a merge. Default is off.
Ignorar os números:	Default is off. Number characters (0-9, ., -) will be ignored in the first part of the analysis in which the line matching is done. In the result the differences will be shown nevertheless, but they are treated as white space.
Ignorar comentários de C/C++:	Por omissão está desligado. As alterações nos comentários serão tratadas como as alterações nos espaços em branco.
Ignorar a capitalização:	Default is off. Case-differences of characters (like A vs. a) will be treated like changes in white space.
Comando do pré-processador:	Veja a próxima secção.
Comando do Pré-processador para a Correspondência de Linhas:	Veja a próxima secção.
Tentar com Persistência:	Tenta com mais afinco encontrar um delta ainda menor. (Por omissão está ligado). Isto irá ser efectivo provavelmente para os ficheiros grandes e complicados. Será também lento para os ficheiros muito grandes.
Atraso no Avanço Automático (ms):	Quando estiver no modo de avanço automático esta opção indica o intervalo de tempo durante o qual mostrar o resultado da selecção antes de saltar para o próximo conflito não resolvido.
Predefinição da junção de espaço em branco com 2/3 ficheiros:	Automatically solve all white-space conflict by choosing the specified file. (Default is manual choice.) Useful if white-space really isn't important in many files. If you need this only occasionally better use Choose A/B/C For All Unsolved Whitespace Conflicts in the Merge menu. Note that if you enable either Ignore numbers or Ignore C/C++ comments then this auto-choice also applies for conflicts in numbers or comments.

Junção de Pastas
Estas opções dizem respeito à análise da pasta e ao tratamento da junção: Veja em Comparação de Pastas/Juntar para mais detalhes.
Existe aqui ainda uma opção que também é relevante para gravar os ficheiros únicos:
Ficheiros de segurança:	When a file is saved and an older version already exists, then the original version will be renamed with an .orig extension. If an old backup file with .orig extension already exists then this will be deleted without backup.

Opções Regionais e da Língua
Língua:	Adjust the language of the user interface. Changing this option doesn't affect the running program. You have to exit and restart KDiff3 so that the language is changed. (This option is not available in the version of KDiff3 because the language is adjustable in the global settings.)
Utilizar a mesma codificação para tudo:	As seguintes opções de codificação poderão ser ajustadas em separado para cada item ou, se esta opção for verdadeira, todos os valores irão usar o primeiro valor.
Codificação Local:	Por cima dos selectores de codificação, aparece uma nota que lhe indica a sua codificação local. (Esta não é ajustável, mas está aqui apenas para o informar, no caso de não saber qual é a sua codificação local e tiver de a seleccionar).
Codificação do Ficheiro para o A/B/C:	Ajuste a codificação do ficheiro para os ficheiros de entrada. Isto provoca algum efeito na forma como os caracteres especiais são interpretados. Dado que poderá ajustar cada codificação em separado, poderá até comparar e juntar ficheiros que foram gravados com codificações diferentes.
Codificação do Ficheiro para Junção de Resultado e Gravação:	Quando tiver editado um ficheiro, poderá então ajustar a codificação que será usada ao gravar para o disco.
Codificação do Ficheiro dos Ficheiros de Pré-processador:	Quando definir pré-processadores, este poderão não ser capazes de lidar com a sua codificação. (p.ex.: Os seus ficheiros estão em Unicode de 16 bits e o seu pré-processador só consegue lidar com ASCII de 8 bits). Com esta opção, poderá definir a codificação do resultado do pré-processador.
Língua da Esquerda-para-a-Direita:	Some languages are written right to left. When this option is enabled, KDiff3 draws the text from right to left in the diff input windows and in the merge output window. Note that if you start KDiff3 with the command line option --reverse then all layouting will be done right to left too. (This is a feature provided by .) This handbook was written assuming that Right To Left Language or reverse layout are disabled. So some references to left or right must be replaced by their respective counterpart if you use these options.

Diversos
These options and actions are available in menus or the buttonbar.
Mostrar os números de linha:	O utilizador pode seleccionar se os números de linhas são mostrados para os ficheiros de entrada.
Mostrar as diferenças de espaços e tabulações:	Algumas das vezes os espaços e tabulações visíveis são incómodos. Poderá com isto desactivar esta funcionalidade.
Mostrar os espaços em branco:	Turn this off to suppress any highlighting of white-space-only changes in the text or overview-columns. (Note that this also applies to changes in numbers or comments if the options Ignore numbers or "Ignore C/C++ comments" are active.)
Opções da vista geral:	These choices are only available when you compare three files. In normal mode all differences are shown in one color-coded overview-column. But sometimes you are especially interested in the differences between only two of these three files. Selecting A vs. B, A vs. C or B vs. C overview will show a second overview column with the required information next to the normal overview.
Quebrar linha nas janelas de diferenças:	Reparte as linhas quando o seu tamanho exceder a largura de uma janela.
Mostrar a Janela A/B/C:	Sometimes you want to use the space on the screen better for long lines. Hide the windows that are not important. (In the Windows menu.)
Comutar a Orientação da Repartição:	Switch between diff windows shown next to each other (A left of B left of C) or above each other (A above B above C). This should also help for long lines. (In the Windows menu.)
Iniciar uma junção rapidamente:	Sometimes you are viewing the deltas and decide to merge. Merge current file in the Directory menu also works if you only compare two files. A single click starts the merge and uses the filename of the last input-file as the default output filename. (When this is used to restart a merge, then the output filename will be preserved.)

Configurar os Atalhos de Teclado
Currently only the version supports user-configurable keyboard-shortcuts. (Settings Configure Shortcuts...)

Comandos do Pré-processador
O KDiff3 suporta duas opções do pré-processador.
Comando do pré-processador:	When any file is read, it will be piped through this external command. The output of this command will be visible instead of the original file. You can write your own preprocessor that fulfills your specific needs. Use this to cut away disturbing parts of the file, or to automatically correct the indentation .
Comando do Pré-processador para a Correspondência de Linhas:	Quando for lido qualquer ficheiro, ele será encaminhado através deste comando externo. Se um comando de pré-processador (ver acima) for também indicado, então o resultado do pré-processador é a entrada para o pré-processador de correspondência de linhas. O resultado só será usado durante a fase de correspondência de linhas da análise. O utilizador poderá escrever o seu próprio pré-processador que corresponda às suas necessidades específicas. Cada linha de entrada terá de ter uma linha de resultado correspondente.
A ideia é permitir ao utilizador uma maior flexibilidade ao configurar o resultado das diferenças. Mas isto necessita de um programa externo e muitos dos utilizadores não querem escrever um. As boas notícias é que, muitas das vezes, o sed ou o perl encarregar-se-ão disso.
Example: Simple testcase: Consider file a.txt (6 lines):

aa
ba
ca
da
eafa

And file b.txt (3 lines):

cg
dg
eg

Without a preprocessor the following lines would be placed next to each other:

aa - cg
ba - dg
ca - eg
da
ea
fa

This is probably not wanted since the first letter contains the actually interesting information. To help the matching algorithm to ignore the second letter we can use a line matching preprocessor command, that replaces g with a:

sed 's/g/a/'

With this command the result of the comparison would be:

aa
ba
ca - cg
da - dg
ea - eg
fa

Internally the matching algorithm sees the files after running the line matching preprocessor, but on the screen the file is unchanged. (The normal preprocessor would change the data also on the screen.)

Bases do sed
This section only introduces some very basic features of sed. For more information see info:/sed or http://www.gnu.org/software/sed/manual/html_mono/sed.html. A precompiled version for can be found at http://unxutils.sourceforge.net. Note that the following examples assume that the sed command is in some directory in the PATH environment variable. If this is not the case, you have to specify the full absolute path for the command. Also note that the following examples use the single quotation mark (') which won't work for . On you should use the double quotation marks (") instead.
In this context only the sed substitute command is used:

sed 's/REGEXP/REPLACEMENT/FLAGS'

Before you use a new command within KDiff3, you should first test it in a console. Here the echo-command is useful. Example:

echo abrakadabra | sed 's/a/o/'
obrakadabra

This example shows a very simple sed-command that replaces the first occurance of a with o. If you want to replace all occurances then you need the g flag:

echo abrakadabra | sed 's/a/o/g'
obrokodobro

The | symbol is the pipe-command that transfers the output of the previous command to the input of the following command. If you want to test with a longer file then you can use cat on Unix-like systems or type on -like systems. sed will do the substitution for each line.

cat filename |sed options

Exemplos para a Utilização do sed no KDiff3

Ignorar Outros Tipos de Comentários
Currently KDiff3 understands only C/C++ comments. Using the Line-Matching-Preprocessor-Command you can also ignore other types of comments, by converting them into C/C++-comments.
To ignore comments starting with #, you would like to convert them to //. Note that you also must enable the Ignore C/C++-Comments option to get an effect. An appropriate Line-Matching-Preprocessor-Command would be:

sed 's/#/\/\//'

Since for sed the / character has a special meaning, it is necessary to place the \ character before each / in the replacement string. Sometimes the \ is required to add or remove a special meaning of certain characters. The single quotation marks (') before and after the substitution-command are important now, because otherwise the shell will try to interpret some special characters like #, $ or \ before passing them to sed. Note that on you will need the double quotation marks (") here. substitutes other characters like %, so you might have to experiment a little bit.

Diff sem Distinguir Capitalização
Use the following Line-Matching-Preprocessor-Command to convert all input to uppercase:

sed 's/\(.*\)/\U\1/'

Here the .* is a regular expression that matches any string and in this context matches all characters in the line. The \1 in the replacement string refers to the matched text within the first pair of \( and \). The \U converts the inserted text to uppercase.

Ignorar as Palavras-Chave do Controlo de Versões
CVS and other version control systems use several keywords to insert automatically generated strings (info:/cvs/Keyword substitution). All of them follow the pattern $KEYWORD generated text$. We now need a Line-Matching-Preprocessor-Command that removes only the generated text:

sed 's/\$\(Revision\|Author\|Log\|Header\|Date\).*\$/\$\1\$/'

The \| separates the possible keywords. You might want to modify this list according to your needs. The \ before the $ is necessary because otherwise the $ matches the end of the line.
Ao experimentar com o sed, você poderá vir a compreender e até a gostar destas expressões regulares. Elas são úteis porque existem muitos outros programas que suportam algumas coisas desse género.

Ignorar os Números
Ignoring numbers actually is a built-in option. But as another example, this is how it would look as a Line-Matching-Preprocessor-command.

sed 's/[0123456789.-]//g'

Any character within [ and ] is a match and will be replaced with nothing.

Ignorar Certas Colunas
Sometimes a text is very strictly formatted, and contains columns that you always want to ignore, while there are other columns you want to preserve for analysis. In the following example the first five columns (characters) are ignored, the next ten columns are preserved, then again five columns are ignored and the rest of the line is preserved.

sed 's/.....\(..........\).....\(.*\)/\1\2/'

Each dot . matches any single character. The \1 and \2 in the replacement string refer to the matched text within the first and second pair of \( and \) denoting the text to be preserved.

Combinar Várias Substituições
Sometimes you want to apply several substitutions at once. You can then use the semicolon ; to separate these from each other.

echo abrakadabra | sed 's/a/o/g;s/\(.*\)/\U\1/'
OBROKODOBRO

Usar o perl em vez do sed
Instead of sed you might want to use something else like perl.

perl -p -e 's/REGEXP/REPLACEMENT/FLAGS'

But some details are different in perl. Note that where sed needed \( and \) perl requires the simpler ( and ) without preceding \.

sed 's/\(.*\)/\U\1/'
perl -p -e 's/(.*)/\U\1/'

Order de Execução de Pré-processadores
Os dados são encaminhados através de todos os pré-processadores internos e externos pela seguinte ordem:
Pré-processador normal,
Pré-processador de Correspondência de Linhas,
Ignorar capitalização (conversão para maiúsculas),
Detecção de Comentários de C/C++,
Ignorar os números,
Ignorar os espaços em branco
Os dados após o pré-processador normal serão preservados para a apresentação e para a junção. As outras operações só modificam os dados que o algoritmo para a correspondência de linhas nas diferenças vê.
Nos casos raros em que você usa um pré-processador normal, repare que o pré-processador da correspondência de linhas vê o resultado no pré-processador normal como dados de entrada.

Aviso
Os comandos do pré-processador são normalmente muito úteis, mas como acontece com qualquer opção que modifica os seus textos ou esconde algumas diferenças automaticamente, você poderá saltar por cima de certas diferenças e, no pior dos casos, destruir dados importantes.
For this reason during a merge if a normal preprocessor-command is being used KDiff3 will tell you so and ask you if it should be disabled or not. But it won't warn you if a Line-Matching-Preprocessor-command is active. The merge will not complete until all conflicts are solved. If you disabled Show White Space then the differences that were removed with the Line-Matching-Preprocessor-command will also be invisible. If the Save-button remains disabled during a merge (because of remaining conflicts), make sure to enable Show White Space. If you don't wan't to merge these less important differences manually you can select Choose [A|B|C] For All Unsolved Whitespace Conflicts in the Merge menu.