parent
e9068beef5
commit
2b949a99f1
@ -39,6 +39,7 @@ disabled if desired.
|
||||
- Toggle between e.g. `()` and `\left(\right)` with `tsd`
|
||||
- Close the current environment in insert mode with `]]`
|
||||
- Insert new command with `<F7>`
|
||||
- Convenient insert mode mappings for faster typing of e.g. maths
|
||||
- Improved folding (`:h 'foldexpr'`)
|
||||
- Improved indentation (`:h 'indentexpr'`)
|
||||
- Improved syntax highlighting
|
||||
|
@ -7,77 +7,78 @@
|
||||
function! vimtex#imaps#init_options() " {{{1
|
||||
call vimtex#util#set_default('g:vimtex_imaps_enabled', 1)
|
||||
call vimtex#util#set_default('g:vimtex_imaps_leader', '`')
|
||||
call vimtex#util#set_default('g:vimtex_imaps_default', [
|
||||
\ { 'map' : ['...', '\dots'], 'leader' : '' },
|
||||
\ { 'map' : ['<m-i>', '\item '], 'leader' : '' },
|
||||
\ { 'map' : ['__', '_\{$1\}'], 'leader' : '', 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['^^', '^\{$1\}'], 'leader' : '', 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['((', '\left($1\right)'], 'leader' : '', 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['[[', '\left[$1\right]'], 'leader' : '', 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['{{', '\left\\{$1\right\\}'], 'leader' : '', 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['i', '\int_{$1}^{$2}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['S', '\sum_{$1}^{$2}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['/', '\frac{$1}{$2}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['0', '\emptyset'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['6', '\partial'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['8', '\infty'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['=', '\equiv'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['\', '\setminus'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['.', '\cdot'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['*', '\times'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['<', '\leq'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['>', '\geq'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['~', '\tilde{$1}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['^', '\hat{$1}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : [':', '\dot{$1}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['_', '\bar{$1}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['lim', '\lim_{$1}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['qj', '\downarrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['ql', '\leftarrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['qh', '\rightarrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['qk', '\uparrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['qJ', '\Downarrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['qL', '\Leftarrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['qH', '\Rightarrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['qK', '\Uparrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'map' : ['a', '\alpha'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['b', '\beta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['c', '\chi'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['d', '\delta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['e', '\varepsilon'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['f', '\varphi'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['g', '\gamma'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['h', '\eta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['k', '\kappa'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['l', '\lambda'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['m', '\mu'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['n', '\nu'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['p', '\pi'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['q', '\theta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['r', '\rho'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['s', '\sigma'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['t', '\tau'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['u', '\upsilon'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['w', '\omega'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['z', '\zeta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['A', '\Alpha'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['B', '\Beta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['G', '\Gamma'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['D', '\Delta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['E', '\Epsilon'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['Z', '\Zeta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['Y', '\Eta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['F', '\Phi'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['G', '\Gamma'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['L', '\Lambda'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['N', '\Nabla'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['Q', '\Theta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['R', '\varrho'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['T', '\Tau'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['U', '\Upsilon'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['W', '\Omega'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['X', '\Xi'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'map' : ['Y', '\Psi'], 'wrapper' : 's:wrap_math'},
|
||||
call vimtex#util#set_default('g:vimtex_imaps_disabled', [])
|
||||
call vimtex#util#set_default('g:vimtex_imaps_list', [
|
||||
\ { 'lhs_rhs' : ['...', '\dots'], 'leader' : '' },
|
||||
\ { 'lhs_rhs' : ['<m-i>', '\item '], 'leader' : '' },
|
||||
\ { 'lhs_rhs' : ['__', '_\{$1\}'], 'leader' : '', 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['^^', '^\{$1\}'], 'leader' : '', 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['((', '\left($1\right)'], 'leader' : '', 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['[[', '\left[$1\right]'], 'leader' : '', 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['{{', '\left\\{$1\right\\}'], 'leader' : '', 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['i', '\int_{$1}^{$2}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['S', '\sum_{$1}^{$2}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['/', '\frac{$1}{$2}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['0', '\emptyset'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['6', '\partial'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['8', '\infty'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['=', '\equiv'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['\', '\setminus'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['.', '\cdot'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['*', '\times'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['<', '\leq'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['>', '\geq'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['~', '\tilde{$1}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['^', '\hat{$1}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : [':', '\dot{$1}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['_', '\bar{$1}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['lim', '\lim_{$1}'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['qj', '\downarrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['ql', '\leftarrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['qh', '\rightarrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['qk', '\uparrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['qJ', '\Downarrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['qL', '\Leftarrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['qH', '\Rightarrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['qK', '\Uparrow'], 'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['a', '\alpha'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['b', '\beta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['c', '\chi'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['d', '\delta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['e', '\varepsilon'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['f', '\varphi'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['g', '\gamma'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['h', '\eta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['k', '\kappa'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['l', '\lambda'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['m', '\mu'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['n', '\nu'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['p', '\pi'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['q', '\theta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['r', '\rho'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['s', '\sigma'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['t', '\tau'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['u', '\upsilon'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['w', '\omega'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['z', '\zeta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['A', '\Alpha'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['B', '\Beta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['G', '\Gamma'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['D', '\Delta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['E', '\Epsilon'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['Z', '\Zeta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['Y', '\Eta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['F', '\Phi'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['G', '\Gamma'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['L', '\Lambda'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['N', '\Nabla'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['Q', '\Theta'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['R', '\varrho'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['T', '\Tau'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['U', '\Upsilon'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['W', '\Omega'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['X', '\Xi'], 'wrapper' : 's:wrap_math'},
|
||||
\ { 'lhs_rhs' : ['Y', '\Psi'], 'wrapper' : 's:wrap_math'},
|
||||
\])
|
||||
endfunction
|
||||
|
||||
@ -90,7 +91,7 @@ endfunction
|
||||
function! vimtex#imaps#init_buffer() " {{{1
|
||||
if !g:vimtex_imaps_enabled | return | endif
|
||||
|
||||
for l:map in g:vimtex_imaps_default
|
||||
for l:map in g:vimtex_imaps_list
|
||||
call vimtex#imaps#add_map(l:map)
|
||||
endfor
|
||||
endfunction
|
||||
@ -98,8 +99,10 @@ endfunction
|
||||
" }}}1
|
||||
|
||||
function! vimtex#imaps#add_map(map) " {{{1
|
||||
let l:lhs = a:map.map[0]
|
||||
let l:rhs = a:map.map[1]
|
||||
let l:lhs = a:map.lhs_rhs[0]
|
||||
if index(g:vimtex_imaps_disabled, l:lhs) > 0 | return | endif
|
||||
|
||||
let l:rhs = a:map.lhs_rhs[1]
|
||||
if match(l:rhs, '$1') > 0 && !s:has_ultisnips | return | endif
|
||||
|
||||
let l:leader = get(a:map, 'leader', g:vimtex_imaps_leader)
|
||||
|
129
doc/vimtex.txt
129
doc/vimtex.txt
@ -37,6 +37,7 @@ CONTENTS *vimtex-contents*
|
||||
Options |vimtex-options|
|
||||
Commands |vimtex-commands|
|
||||
Map definitions |vimtex-mappings|
|
||||
Insert mode mappings |vimtex-imaps|
|
||||
Completion |vimtex-completion|
|
||||
Complete labels |vimtex-complete-labels|
|
||||
Complete citations |vimtex-complete-cites|
|
||||
@ -99,6 +100,7 @@ Feature overview~
|
||||
- Toggle between e.g. `()` and `\left(\right)` with `tsd`
|
||||
- Close the current environment in insert mode with `]]`
|
||||
- Insert new command with `<F7>`
|
||||
- Convenient insert mode mappings for faster typing of e.g. maths
|
||||
- Folding
|
||||
- Indentation
|
||||
- Improved syntax highlighting
|
||||
@ -230,10 +232,11 @@ suffix as a |plaintex|. To prevent this, one may set the option
|
||||
==============================================================================
|
||||
USAGE *vimtex-usage*
|
||||
|
||||
Default mappings |vimtex-default-mappings|
|
||||
Options |vimtex-options|
|
||||
Commands |vimtex-commands|
|
||||
Mappings |vimtex-user-mappings|
|
||||
Default mappings |vimtex-default-mappings|
|
||||
Options |vimtex-options|
|
||||
Commands |vimtex-commands|
|
||||
Map definitions |vimtex-mappings|
|
||||
Insert mode mappings |vimtex-imaps|
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
Default mappings~
|
||||
@ -243,6 +246,10 @@ Default mappings~
|
||||
mappings are listed below. Most of the mappings are also available as
|
||||
commands, see |vimtex-commands|.
|
||||
|
||||
In addition to the mappings listed below, |vimtex| provides convenient insert
|
||||
mode mappings to make it easier and faster to type mathematical equations.
|
||||
This feature is explained in more detail later, see |vimtex-imaps|.
|
||||
|
||||
If one prefers, one may disable the default mappings through the option
|
||||
|g:vimtex_mappings_enabled|. One can then define custom mappings through the
|
||||
listed RHS <plug>-maps or by mapping the available commands.
|
||||
@ -394,6 +401,30 @@ Options~
|
||||
\ "subsubsection",
|
||||
\ ]
|
||||
<
|
||||
*g:vimtex_imaps_enabled*
|
||||
Use this option to disable/enable insert mode mappings.
|
||||
|
||||
Default value: 1
|
||||
|
||||
*g:vimtex_imaps_leader*
|
||||
The default leader key for insert mode mappings.
|
||||
|
||||
Default value: '`'
|
||||
|
||||
*g:vimtex_imaps_disabled*
|
||||
A list of mappings to disable. That is, any left-hand side that matches
|
||||
a string in this list will not be mapped to its corresponding right-hand
|
||||
side. This may be used to selectively disable one or more from the default
|
||||
list of mappings.
|
||||
|
||||
Default value: []
|
||||
|
||||
*g:vimtex_imaps_list*
|
||||
The list of mappings to generate on start up.
|
||||
|
||||
Default value: Complicated, please see the source file for exact value
|
||||
`autoload/vimtex/imaps.vim`
|
||||
|
||||
*g:vimtex_indent_enabled*
|
||||
Use this option to disable/enable |vimtex| indentation.
|
||||
|
||||
@ -989,6 +1020,92 @@ Map definitions~
|
||||
*<plug>(vimtex-[[)*
|
||||
Section backward (exclusive).
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
Map definitions~
|
||||
*vimtex-imaps*
|
||||
|
||||
The following feature is optional. It is enabled by default, but may be
|
||||
disabled with |g:vimtex_imaps_enabled|.
|
||||
|
||||
Some LaTeX commands are very common, and so it is both natural and convenient
|
||||
to have insert mode mappings/abbreviations for them. |vimtex| therefore
|
||||
provides a list of such mappings that are enabled by default, see
|
||||
|g:vimtex_imaps_list|. Most of the mappings utilize a map leader defined by
|
||||
|g:vimtex_imaps_leader|. Also, many of the mappings are only active inside
|
||||
mathematical environments.
|
||||
|
||||
Some of the default mappings utilize the function |UltiSnips#Anon| from
|
||||
|UltiSnips| in order to provide a more advanced snippet-like functionality.
|
||||
This is in no way intended to replace |UltiSnips|. It is instead meant to be
|
||||
used for very simple things. For instance, the sequence `((` expands directly
|
||||
to `\left(|\right)` (though only when inside a math environment). The
|
||||
|UltiSnipsJumpForward| trigger may then be used to conveniently move the
|
||||
cursor out of the parantheses.
|
||||
|
||||
It is of course possible to customize the list of mappings. First, one may
|
||||
specifically disable a default mapping through |g:vimtex_imaps_disabled|.
|
||||
Second, one may specify |g:vimtex_imaps_list|, which will overwrite the
|
||||
default list. Finally, one may add new maps through calls to the function
|
||||
|vimtex#imap#add_map|. The following are some examples of how to customize the
|
||||
mappings: >
|
||||
|
||||
" Disable <m-i> mapping
|
||||
let g:vimtex_imaps_disabled = ['<m-i>']
|
||||
|
||||
" Define three of the default mappings
|
||||
let g:vimtex_imaps_list = [
|
||||
\ { 'lhs_rhs' : ['__', '_\{$1\}'],
|
||||
\'leader' : '',
|
||||
\'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['^^', '^\{$1\}'],
|
||||
\'leader' : '',
|
||||
\'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\ { 'lhs_rhs' : ['((', '\left($1\right)'],
|
||||
\'leader' : '',
|
||||
\'wrapper' : 's:wrap_math_ultisnips'},
|
||||
\]
|
||||
|
||||
" Add custom mapping through vimtex#imap#add_map
|
||||
call vimtex#imaps#add_map({
|
||||
\ 'lhs_rhs' : [ 'v', '\vec{$1}'],
|
||||
\ 'wrapper' : 's:wrap_math_ultisnips'})
|
||||
<
|
||||
*vimtex#imaps#add_map*
|
||||
|
||||
This function is used to add new insert mode mappings. It takes a single
|
||||
dictionary argument: >
|
||||
|
||||
map = {
|
||||
\ 'lhs_rhs' : [lhs, rhs],
|
||||
\ 'leader' : leader_key,
|
||||
\ 'wrapper' : function_name
|
||||
\ }
|
||||
|
||||
Explanation of the keys:
|
||||
|
||||
lhs_rhs~
|
||||
The only mandatory argument: It is a list with two elements, `lhs` and
|
||||
`rhs`, respectively. If nothing else is specified, |vimtex#imaps#add_map|
|
||||
simply creates an insert mode mapping from `lhs` to `rhs`.
|
||||
|
||||
leader~
|
||||
Custom leader key. If the key is not present, then |g:vimtex_imaps_leader|
|
||||
is used as leader key.
|
||||
|
||||
wrapper~
|
||||
The name of a wrapper function that is applied to `rhs`. Three functions
|
||||
are available from |vimtex|:
|
||||
|
||||
`s:wrap_math` Only define `rhs` if inside a math environment.
|
||||
`s:wrap_ultisnips` Send `rhs` through `UltiSnips#Anon` in order
|
||||
to create an anonymous snippet.
|
||||
`s:wrap_math_ultisnips` Same as `s:wrap_ultisnips`, except it is only
|
||||
expanded when inside a math environment.
|
||||
|
||||
Of course, one may use custom wrapper functions. To write a custom wrapper
|
||||
function, please see how the |vimtex| wrappers are written for examples on
|
||||
how it is done.
|
||||
|
||||
==============================================================================
|
||||
COMPLETION *vimtex-completion*
|
||||
|
||||
@ -1424,6 +1541,10 @@ The following changelog only logs particularly important changes, such as
|
||||
changes that break backwards compatibility. See the git log for the detailed
|
||||
changelog.
|
||||
|
||||
2015-10-19: Added convenient insert mode mappings~
|
||||
I've merged the `math_mappings` branch (see #172 and #251). It adds the
|
||||
feature that is explained in |vimtex-imaps|.
|
||||
|
||||
2015-06-06: Minor but convenient restructuring (++)~
|
||||
I've changed a lot of the code structure in relatively small ways. For
|
||||
instance, instead of referring to the particular data blobs through the global
|
||||
|
Loading…
Reference in New Issue
Block a user