Help:Extension:CodeMirror/pt-br

PD Nota: Ao editar esta página, você concorda em publicar suas contribuições no âmbito da licença CC0. Veja as páginas de ajuda sob domínio público para mais informações. PD

A extensão CodeMirror é um editor que fornece realce de sintaxe. It supports a variety of languages, notably MediaWiki wikitext, JavaScript, CSS, JSON and Lua. Isso pode facilitar a edição, usando cores e sombreamento para separar visualmente o texto simples de outras sintaxes, como links, predefinições e outras marcações de wikitexto.

Uso

Ativação

O CodeMirror pode ser ativado ao definir Ativar realce de sintaxe nas suas preferências. No WikiEditor (também conhecido como editor de 2010, ativado com a preferência Ativar a barra de ferramentas de edição), ele também pode ser ativado ou desativado usando o botão de realce " Sintaxe" na barra de ferramentas. No editor de 2017, você pode ativar ou desativar o CodeMirror clicando no botão "Opções da página" na barra de ferramentas e, em seguida, selecionando "Realce de sintaxe".

Atalhos de teclado

Alguns atalhos de teclado não se aplicam ao editor de 2017, que possui seu próprio conjunto de atalhos.

You can review keyboard shortcuts by opening the help dialog with Ctrl+⇧ Shift+/.

Lista de atalhos de teclado
Atalhos Atalhos (Mac OS) Descrição
Navegação
Ctrl+ Alt+ Mover o cursor uma palavra para a esquerda.
Ctrl+ Alt+ Mover o cursor uma palavra para a direita.
Alt+ Alt+ Mover as linhas selecionadas uma linha para cima.
Alt+ Alt+ Mover as linhas selecionadas uma linha para baixo.
⇧ Shift+Alt+ ⇧ Shift+Alt+ Duplicar as linhas selecionadas e manter a seleção na cópia superior.
⇧ Shift+Alt+ ⇧ Shift+Alt+ Duplicar as linhas selecionadas e manter a seleção na cópia inferior.
Escape Escape Reduzir várias seleções ao intervalo principal ou a um cursor, caso haja apenas uma seleção.
Estilo de texto
Ctrl+b ⌘ Command+b Estilizar o texto selecionado em negrito.
Ctrl+i ⌘ Command+i Estilizar o texto selecionado em itálico.
Ctrl+k ⌘ Command+k Inserir ligação
Ctrl+⇧ Shift+6 ⌘ Command+⇧ Shift+6 Estilizar o texto selecionado como código de computador.
Ctrl+⇧ Shift+5 ⌘ Command+⇧ Shift+5 Estilizar o texto selecionado com tachado.
Ctrl+, ⌘ Command+, Estilizar o texto selecionado como subscrito.
Ctrl+. ⌘ Command+. Estilizar o texto selecionado como código de computador.
Ctrl+u ⌘ Command+u Estilizar o texto selecionado como subscrito.
Limpar formatação
Ctrl+[ ⌘ Command+[ Remover a indentação das linhas selecionadas.
Ctrl+] ⌘ Command+] Adicionar indentação às linhas selecionadas.
Ctrl+7 Ctrl+7 Formatar o texto selecionado como pré-formatado.
Ctrl+8 ⌘ Command+8 Formatar como uma citação em bloco.
Ctrl+1-6 ⌘ Command+1-6 Adicionar um título do nível indicado (de 1 a 6).
Pesquisando
Ctrl+f ⌘ Command+f Abrir o painel de pesquisa.
Ctrl+g ⌘ Command+g Encontrar a próxima ocorrência da string de pesquisa.
⇧ Shift+Ctrl+g ⇧ Shift+⌘ Command+g Encontrar a ocorrência anterior da string de pesquisa.
Ctrl+d ⌘ Command+d Selecionar a próxima ocorrência da seleção ou palavra atual, criando múltiplas seleções.
Ctrl+Alt+g ⌘ Command+Alt+g Abrir o painel "Ir para a linha".
Inserir
Ctrl+↵ Enter ⌘ Command+↵ Enter Inserir uma linha em branco abaixo da linha atual.
Ctrl+⇧ Shift+k ⌘ Command+⇧ Shift+k Inserir uma referência.
Ctrl+/ ⌘ Command+/ Inserir um comentário ou transformar o texto selecionado em um comentário.
Dobrar código (Code folding)
Ctrl+⇧ Shift+[ ⌘ Command+Alt+[ Dobrar o código atualmente selecionado.
Ctrl+⇧ Shift+] ⌘ Command+Alt+] Desdobrar o código selecionado.
Ctrl+Alt+[ Ctrl+Alt+[ Recolher todo o código.
Ctrl+Alt+] Ctrl+Alt+] Expandir todo o código.
Outros
Ctrl+⇧ Shift+/ Ctrl+⇧ Shift+x Exibir o diálogo de ajuda dos atalhos de teclado.
Ctrl+⇧ Shift+, ⌘ Command+⇧ Shift+, Abrir o painel de preferências do CodeMirror.
Ctrl+⇧ Shift+x ⌘ Command+⇧ Shift+x Alternar a visualização do editor entre da direita para a esquerda e da esquerda para a direita.
Modificadores do cursor
Ctrl+click ⌘ Command+click Adiciona um cursor ou seleção adicional na área clicada.
Ctrl+click on page titles ⌘ Command+click on page titles Abrir links no código wikitexto.
Alt+click and drag Alt+click and drag Fazer uma seleção retangular.

Recursos

For technical reasons, some features are unavailable in the 2017 editor.

Acesso às preferências

Versão do MediaWiki:
1.44

A maioria dos recursos documentados aqui pode ser desativada ou ativada por cada usuário individualmente. Para abrir o painel de preferências, pressione Ctrl+⇧ Shift+, (ou ⌘ Command+⇧ Shift+, no macOS). Se você usar o WikiEditor, também poderá acessar suas preferências do CodeMirror clicando no botão na seção Avançado da barra de ferramentas. Suas preferências do CodeMirror serão lembradas em diferentes dispositivos e sessões.

Some preferences are only available in the "full" preferences dialog. This is accessible by clicking on todas as preferências link in the preferences panel, or directly by pressing Alt+⇧ Shift+,.

Editing MediaWiki Wikitexto often has different needs than editing proper "code" such as JavaScript or Lua. For this reason, preferences are stored separately for wikitext and non-wikitext, allowing you to customize the two experiences differently.

Correspondência de colchetes

Correspondência de colchetes em ação

Quando o cursor está diretamente ao lado de um colchete, o recurso destaca o colchete correspondente.

Dobramento de código

Versão do MediaWiki:
1.43
Dobramento de código em w:Barack Obama.

O dobramento de código permite recolher parâmetros de predefinições, tags de extensões e outros blocos de código. Isso pode facilitar bastante o gerenciamento de predefinições grandes e complexas.

Uso

Quando o cursor ou a seleção cobre qualquer parte de uma sintaxe compatível, um ícone de dica aparece logo acima do texto. Ao clicar nele, o código é recolhido, deixando visível apenas o nome da predefinição ou da tag.

O código dobrado exibirá o nome da predefinição ou da tag seguido do ícone de reticências . Clicar nesse ícone expandirá o código de volta ao seu estado original.

Atalhos de teclado
Atalhos Atalhos (Mac OS) Descrição
Ctrl+⇧ Shift+[ ⌘ Command+Alt+[ Dobrar o código selecionado.
Ctrl+⇧ Shift+] ⌘ Command+Alt+] Desdobrar o código selecionado.
Ctrl+Alt+[ Ctrl+Alt+[ Recolher todo o código.
Ctrl+Alt+] Ctrl+Alt+] Expandir todo o código.

Personalização

Se você quiser manter o atalho de teclado para dobrar templates, mas ocultar o componente visual, pode fazer isso adicionando o seguinte ao seu CSS pessoal:[1]

.cm-tooltip-fold {
	display: none;
}

Preenchimento automático

Versão do MediaWiki:
1.44
Example showing autocompletion of parser functions.

This feature provides autocompletion of palavras mágicas, parser extension tags, and URL protocols. If you enter {{#, you should see a list of all parser functions that start with #. Similarly, typing double underscores (__) will show a list of double-underscored magic words. You can continue to type to narrow your search. Use the arrow keys to select the desired text, and hit the ↵ Enter or Tab ↹ key to make your selection. Autocompletion does not work for templates, or for magic words or parser functions that do not begin with # or __ by default. To get autocompletion in that case, press ⇧ Shift+↵ Enter after you've typed {{ and the first few characters of the template, magic word or parser function you're looking for. The same shortcut also works to enable autocompletion of wikilinks, including file links.

Linting

Versão do MediaWiki:
1.45
Example showing the linter in wikitext

CodeMirror includes a linter. This performs static code analysis in real time, surfacing errors or other potential problems with your code without you having to save. This works for all languages supported by CodeMirror, including wikitext.

Linting is available as the Checar o código option in your CodeMirror preferences. When enabled, you will see a status bar at the bottom of the editor listing the number of errors, warnings, and informational diagnostics. Issues are underlined in the source text. Hovering over them or moving the cursor to the issues will reveal more information, and in some cases the linter may offer a button to quickly fix the issue. On the opposite side of the status bar, you are shown the numbers for the current line number, character, and selection length.

See Help:Extension:CodeMirror/Wikitext linting for the list of the available lint rules for wikitext.

Note that while the linter is a useful tool to assist with fixing various issues, it is not an authority and may have stylistic opinions not shared by all editors.

Versão do MediaWiki:
1.44

You can quickly open links specified in the wikitext. Do this by holding down the Ctrl key (or ⌘ Command on macOS) and clicking on a page title inside of link syntax, such as [[Main Page]]. Clicking this case would open Main Page in a new tab.

This feature also works for template names and file names.

Line numbering

Note how the line numbering knew to account for the lines contained in the collapsed templates.

When enabled, line numbers are automatically displayed in all editors. On the Wikimedia wikis, it is only enabled for specific namespaces of specific wikis.[2]

Line numbers will take into account any hidden lines, such as those through code folding.

Highlight the active line

Versão do MediaWiki:
1.44

In your CodeMirror preferences, you can select Destacar a linha ativa to enable this feature, which can make it easier to tell which line of text the cursor is on, especially on large pages.

Line wrapping

Versão do MediaWiki:
1.44

Line wrapping is the default behaviour in most editors. Sometimes you may want to disable this, especially when writing complex wikitext or other code. You can disable line wrapping in your CodeMirror preferences.

Multiple cursors and selections

You can add additional cursors or selections by holding the Ctrl key (or ⌘ Command on macOS) and clicking on the desired content or cursor placement. After doing so, any changes you make will be applied to all the selections at the same time.

You can also press Ctrl+d (or ⌘ Command+d on macOS) to select the next occurrence of the current selection or word, which create multiple selections. This can be useful as a quick find and replace feature.

Highlight references

The "Highlight the contents of <ref> tags" preference will make all contents within <ref>...</ref> tags be highlighted with a pale green background color.

This helps differentiate reference content from prose.

In addition, the "Fold all <ref> tags by default" preference will make all <ref>...</ref> tags folded when first starting an editing session.

Note this feature can be potentially slow, as it needs to scan the entire document. The slowness will only occur once when initially opening the editor.

Highlight special characters

By default, CodeMirror will highlight non-printable control characters and other characters such as non-breaking spaces. Control characters appear as a red dot, while non-breaking spaces are displayed as a faint gray dot. Hovering over these characters will show a tooltip stating which character it is.

If desired, you can disable this feature in your CodeMirror preferences.

Highlight whitespace

Enabling "Highlight whitespace" will highlight the whitespace characters with a gray dot, or a wide arrow for the tab character.

The "Highlight trailing whitespace" setting will highlight spaces, tabs and other invisible characters at the end of a sentence.

Colorblind mode

For users who have difficulty distinguishing between colors, CodeMirror offers a colorblind-friendly mode. This feature can be activated on wikis with CodeMirror enabled with Ativar esquema compatível com daltônicos para realce de sintaxe ao editar o wikitexto in your preferences.

With the colorblind-friendly scheme active, the colors of the following page elements change:

Headings, symbols, signatures, section names, magic words#E4A400
Predefinições#9C3A00
HTML tags, references, mathematical expressions#56B4E9
Variáveis#009E73

In addition, background highlights and colors are removed from all text and objects. Bolding and underlining behavior remains unaffected.

Support for the 2017 wikitext editor

Due to various technical conflicts, CodeMirror support in the Editor de wikitexto 2017 is limited.

Features such as code folding that change the appearance of the wikitext cannot feasibly be supported in the 2017 editor, because the 2017 editor needs focus on its editor for users to be able to use its toolbar and other contextual tools. Similarly, CodeMirror needs focus on its editor for its features to work.

To get around this, the CodeMirror editor is overlaid on top of the 2017 editor, with both editors running in parallel. For this reason the two editors need to visually match each other exactly, so only features that involve basic color changes such as the highlighting of references can be supported.

The 2017 editor also requires the viewport to be the full length of the document. This can cause significant performance issues, since CodeMirror has to highlight the entire document instead of only what is currently visible to the user. As a temporary solution, CodeMirror is automatically disabled on very large pages in order to prevent browser crashes and other performance problems that could hinder the editing experience.

Long-term, the hope is to rework the 2017 editor to be more compatible with CodeMirror.

Color and style customization

Notas

  1. Your personal CSS is at Special:MyPage/common.css. You can also make your changes take effect globally if GlobalCssJs is installed. On Wikimedia wikis, your global CSS is at meta:Special:MyPage/global.css.
  2. Controlled by the $wgCodeMirrorLineNumberingNamespaces configuration setting. See Extension:CodeMirror#Configuration for more information.