default_brackets.md
January 15, 2021 · View on GitHub
Default bracket mappings
By default, lh-brackets comes with a few ready-to-use mappings:
- some are global and apply to all filetypes,
- other are specialized for various filetypes:
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
.vimrcby settingg:cb_no_default_bracketsto 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}ifg:cb_jump_over_newlinesequals to 1 (default case). If you want to jump after the}only if it's exactly right after the cursor, then setg:cb_jump_over_newlinesto 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\cwhen I need to type several things). -
;will try to close parenthesis -- set(bpg):[{ft}_]semicolon_closes_bracketto 0 to inhibit this setting. -
<bs>take care of semi-colons after the closing curly-bracket -- set(bpg):[{ft}_]semicolon_closes_bracketto 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 likestd::vector, lh-cpp v2.2.1+ is required
HTML mappings
The main differences from the global table are:
- Typing
<twice results in<, and<>results in>. - 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>{replacebegin-endblock 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, awhile, 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