Skip to content

Latest commit

 

History

History
163 lines (136 loc) · 11.5 KB

default_brackets.md

File metadata and controls

163 lines (136 loc) · 11.5 KB

Default bracket mappings

By default, lh-brackets comes with a few ready-to-use mappings:

The default mappings can be inhibited with the options (bpg):cb_no_default_brackets, g:cb_enable_default and g:cb_disable_default. See :h :Brackets-default.

Global mappings

The following mappings apply to all filetypes (unless specified otherwise, or specialized).

in mode insert visual normal
keys expands into .. surrounds the selection with ... 2 surrounds the current ...
( (<cursor>)«» (<selection>) word
[ [<cursor>]«» 1 1
<leader>[ [<selection>] word
{ {<cursor>}«»3 {<selection>} word
<leader>{ {\n<selection>\n}«» line
" (1 double quote) "<cursor>"«» 1 1
"" "<selection>" word
' '<cursor>'«»4 1 1
'' (2 single quotes) '<selection>' word
<leader>< <<selection>> word

Notes:

  • 1 Not defined to avoid hijacking default vim key bindings.
  • 2 The visual mode mappings do not surround the current marker/placeholder selected, but trigger the INSERT-mode mappings instead.
  • 3 No newline is inserted by default. However, hitting <cr> in the middle of a pair of curly-brackets will expand into {\n<cursor>\n}.
  • 4 This mapping is neutralized for text filetypes -- the list of text-filetypes is defined in lh#ft#is_text()
  • «» represents a marker/placeholder, it may be expanded with other characters like <++> depending on your preferences.
  • These mappings can be disabled from the .vimrc by setting g:cb_no_default_brackets to 1 (default: 0)

C and C++ mappings

See lh-cpp documentation for the complete mappings table.

The main differences from the global table are:

  • } jumps to the next non whitespace/newline character that is a } if g:cb_jump_over_newlines equals to 1 (default case). If you want to jump after the } only if it's exactly right after the cursor, then set g:cb_jump_over_newlines to 0 in your .vimrc. See #26. When not jumping, } is simply inserted.

  • In visual mode, <localleader>{ surrounds the selection with a pair of curly brackets (and newlines are introduced).

  • <tt> is recognized as an opening bracket (I use it a lot to write Doxygen code instead of \c when I need to type several things).

  • ; will try to close parenthesis -- set (bpg):[{ft}_]semicolon_closes_bracket to 0 to inhibit this setting.

  • <bs> take care of semi-colons after the closing curly-bracket -- set (bpg):[{ft}_]semicolon_closes_bracket to 0 to inhibit this setting.

in mode insert
keys expands into ..
< after #include, template, typename, _cast or standard types <<cursor>>;
{ after struct, class, enum or union {<cursor>};
[ after a [ [[<cursor>]]«»
] before ]] close all ]]

Notes

  • For < to expand into <|> after standard types like std::vector, lh-cpp v2.2.1+ is required

HTML mappings

The main differences from the global table are:

  • Typing < twice results in &lt;, and <> results in &gt;.
  • In visual mode, <localleader>< surrounds the selection with a pair of angle brackets.

Javascript mappings

The main differences from the global table are:

  • In visual mode, <localleader>{ surrounds the selection with a pair of curly brackets (and newlines are introduced).

Markdown mappings

New mappings are avaible.

in mode insert visual normal
keys expands into .. surrounds the selection with ... 2 surrounds the current ...
_ _<cursor>_<++> 3 _<selection>_ word
_ after a _ __<cursor>__<++> n/a n/a
* *<cursor>*<++> 3,4 *<selection>* word
* after a * **<cursor>**<++> n/a n/a
` `<cursor>`<++> 5 `<selection>` word
~ <del><cursor></del>«» 1 1
<localleader>~ <del><cursor></del> word

Notes:

  • 1 Not defined to avoid hijacking default vim key bindings.
  • 2 The visual mode mappings do not surround the current marker/placeholder selected, but trigger the INSERT-mode mappings instead.
  • 3 Within a pair of backquotes (code marker), formatting pairs are not expanded
  • 4 Right after spaces at the beginning of the line, * is not expanded: it will serve to start a new point in a bullet-list.
  • 5 When type after a dollar sign, backtick will get expanded into $`<cursor>`$<++>, and $ will move the cursor and consume any placeholder if typed between and backtick and an existing dollar.

Perl mappings

The main differences from the global table are:

  • In visual mode, <localleader>{ surrounds the selection with a pair of curly brackets (and newlines are introduced).
  • In visual mode, <localleader>< surrounds the selection with a pair of angle brackets.

Ruby mappings

  • In normal mode, <C-X>{ replace begin-end block by {-}, or the other way around.

(La)TeX mappings

New and specialized mappings are avaible.

in mode insert visual normal
keys expands into .. surrounds the selection with ... 2 surrounds the current ...
( (<cursor>)<++> (<selection>) word
( after a \ \(<cursor>\)<++> n/a n/a
{ {<cursor>}<++> {<selection>} word
{ after a \ \{<cursor>\}<++> n/a n/a
[ [<cursor>]<++> [<selection>] word
[ after a \ \[<cursor>\]<++> n/a n/a
<leader>[ [<selection>] word
$ $<cursor>$<++> 1 1
<leader>$ $<selection>$ word

Notes:

  • 1 Not defined to avoid hijacking default vim key bindings.
  • 2 The visual mode mappings do not surround the current marker/placeholder selected, but trigger the INSERT-mode mappings instead.
  • In (La)TeX, <++> is used as a placeholder instead of «».

VimL mappings

New and specialized mappings are avaible.

in mode insert visual normal
keys expands into .. surrounds the selection with ... 2 surrounds the current ...
( (<cursor>)«» (<selection>) word
( after a \ \(<cursor>\)«» n/a n/a
< <<cursor>>«» 5 1 1
<leader>< <<selection>> word
" "<cursor>"«» 6 1 1

Notes:

  • 1 Not defined to avoid hijacking default vim key bindings.
  • 2 The visual mode mappings do not surround the current marker/placeholder selected, but trigger the INSERT-mode mappings instead.
  • 5 except after an if, a while, or within comments. Still this rule knowns an exception: within a string, or after a \, < is always converted to <>. Does not handle special characters like '< and '>
  • 6 except for comments, and special attention is given when the cursor is within strings