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

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.

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.

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 "Highlight the active line" 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 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.

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.

Bidi isolation

Nota Nota:

On right-to-left pages, CodeMirror can isolate HTML and other tags as bidirectional text, which can improve readability. The standard algorithm for the layout of text places neutral punctuation characters between right-to-left text on the wrong side. With bidi isolation, we can correct this so it reads more legibly:

CodeMirror without bidi isolation
CodeMirror with bidi isolation

Color and style customization

This is a partial list of the CodeMirror CSS classes. The complete list of default CodeMirror styling definitions is on Gerrit.

The colors and styles used in CodeMirror can be overridden by defining your own styles for the classes in the table below in your personal CSS.[1] Please be aware that changing some things like the line height or font size may not work in the 2017 wikitext editor.

CSS class(es) Element CodeMirror styling
.cm-mw-skipformatting leading space foo bar
.cm-mw-list asterisk or number sign * foo bar, # foo bar
.cm-mw-signature,
.cm-mw-hr
signature, horizontal rule , ----
.cm-mw-indenting colons ::: foo bar
.cm-mw-html-entity HTML entities &
.cm-mw-comment HTML comment <!-- comment -->
.cm-mw-apostrophes-bold,
.cm-mw-apostrophes-italic
bold and italic '''bold''' ''italic''
Headings
.cm-mw-section-1 level 1 heading[3] = Heading =
.cm-mw-section-2 level 2 heading[3] == Heading ==
.cm-mw-section-3 level 3 heading === Heading ===
.cm-mw-section-4 level 4 heading ==== Heading ====
.cm-mw-section-5 level 5 heading ===== Heading =====
.cm-mw-section-6 level 6 heading ====== Heading ======
.cm-mw-section-header equal signs ==
Predefinições
exemplo {{cite book|title=foo bar}}
.cm-mw-template other template content foo bar
.cm-mw-template-name template name cite book
.cm-mw-template-argument-name template parameters title=
.cm-mw-template-delimiter pipe |
.cm-mw-template-bracket opening/closing brackets {{ }}
.cm-mw-template-ground
.cm-mw-template2-ground
.cm-mw-template3-ground
whole template
(the number is the level of nesting)
{{foo|{{cite book|title=foo bar}}}}
Variables
example {{{foo|bar}}}
.cm-mw-templatevariable variável bar
.cm-mw-templatevariable-name nome de variável com tripla barra foo
.cm-mw-templatevariable-bracket opening/closing brackets {{{ }}}
.cm-mw-templatevariable-delimiter pipe |
Parser functions
exemplo {{#assessment: A | High }}
.cm-mw-parserfunction parser function parameters High
.cm-mw-parserfunction-name parser function name PAGENAME #invoke
.cm-mw-parserfunction-bracket opening/closing brackets {{ }}
.cm-mw-parserfunction-delimiter delimiter :
Tags de extensão
Note: Extension may use their own styles and rules for highlighting text within the extension tag.
exemplo <poem style="padding: 1em;">string
whole line
string</poem>
.cm-mw-exttag text inside tags string
.cm-mw-exttag-name,
.cm-mw-ext-poem[4]
nome da etiqueta poem
.cm-mw-exttag-bracket opening/closing brackets < >
.cm-mw-tag-ref reference content <ref>{{cite web|url=https://example.org}}</ref>
.cm-mw-exttag-attribute
.cm-mw-exttag-attribute-value
reference attributes style="padding: 1em;"
HTML tags
example <span style="foo">foo bar</span>
.cm-mw-htmltag-name HTML tag span
.cm-mw-htmltag-bracket opening/closing brackets < >
.cm-mw-htmltag-attribute
.cm-mw-htmltag-attribute-value
parameters and values style="foo"
superscript
subscript
foo<sup>bar</sup>
foo<sub>bar</sub>
Pre-formatted text
.cm-mw-tag-pre pre-formatted text <pre>foo bar</pre>
.cm-mw-tag-nowiki nowiki text <nowiki>foo bar</nowiki>
Internal links
exemplo [[foo bar]] [[foo#section|bar]]
.cm-mw-link-pagename internal link target foo bar
.cm-mw-link # character #section
.cm-mw-link-tosection characters after the # #section
.cm-mw-link-bracket opening/closing brackets [[ ]]
.cm-mw-link-text link label (no additional formatting)
.cm-mw-link-delimiter pipe |
.cm-mw-pagename internal link targets foo bar
External links
exemplo https://www.example.org
[https://www.example.org]
[https://www.example.org example.org]
.cm-mw-extlink,
.cm-mw-free-extlink
external link target www.example.org
.cm-mw-extlink-protocol,
.cm-mw-free-extlink-protocol
protocolo https://
.cm-mw-extlink-text rótulo do link (no additional formatting)
.cm-mw-extlink-bracket opening/closing brackets [ ]
Tabelas
example {| class="wikitable"
|-
! Header text !! Header text
|-
| Example || Example
|}
.cm-mw-table-bracket opening/closing brackets and pipe {| |}
.cm-mw-table-delimiter row and column separators | |- !
.cm-mw-table-definition
.cm-mw-table-definition-value
table classes and styles class="wikitable"
.cm-mw-table-caption caption text |+ caption
Other
.cm-mw-double-underscore magic words __TOC__
.cm-mw-list semicolon (definition lists) ;Foo:Bar
.cm-special-char-nbsp non-breaking space · ·
.cm-specialChar control characters


Notas

  1. 1 2 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.
  3. 1 2 The size is not changed in the 2017 wikitext editor.
  4. Where "poem" is the name of the tag.