Closed mateusbraga closed 9 years ago
Yes, of course! Sorry but I don't know latex. Please tell me what you want since I will give you an advice.
The rules would be the same as you already have right now for '(', ' and ".
In my case, I would add '$' to this list of custom characters and everytime I time $ I would get $|$.
Sorry, I found a bug related '$' character. I have fixed this bug and you can define '$' rule as follows.
" Please add below in your vimrc
call lexima#add_rule({'char': '$', 'input_after': '$', 'filetype': 'latex'})
call lexima#add_rule({'char': '$', 'at': '\%#\$', 'leave': 1, 'filetype': 'latex'})
call lexima#add_rule({'char': '<BS>', 'at': '\$\%#\$', 'delete': 1, 'filetype': 'latex'})
You will get
Before | Input | After |
---|---|---|
| |
$ |
$|$ |
$|$ |
$ |
$$| |
$|$ |
<BS> |
| |
To get it to work I added the following to my .vimrc
autocmd BufRead,BufNewFile *.tex setlocal filetype=tex
autocmd FileType tex call lexima#add_rule({'char': '$', 'input_after': '$', 'filetype': 'tex'})
autocmd FileType tex call lexima#add_rule({'char': '$', 'at': '\%#\$', 'leave': 1, 'filetype': 'tex'})
autocmd FileType tex call lexima#add_rule({'char': '
For anyone interested in this, see my mateusbraga/vimconfig.
Thanks!
I am reopening this because I think there is a bug in the add_rule. If I put the calls outside of the autocmd, it does not work.
Rephrasing: Adding the following lines to .vimrc does not work even when filetype=tex.:
call lexima#add_rule({'char': '$', 'input_after': '$', 'filetype': 'tex'})
call lexima#add_rule({'char': '$', 'at': '\%#\$', 'leave': 1, 'filetype': 'tex'})
call lexima#add_rule({'char': '
But adding the lines from the previous comment work.
I think it is related to your plugin checking the filetype before it is actually set, but I don't know if that is true.
I noticed that *.tex
file's filetype is plaintex
.
Please try below
call lexima#add_rule({'char': '$', 'input_after': '$', 'filetype': ['tex', 'plaintex']})
call lexima#add_rule({'char': '$', 'at': '\%#\$', 'leave': 1, 'filetype': ['tex', 'plaintex']})
call lexima#add_rule({'char': '<BS>', 'at': '\$\%#\$', 'delete': 1, 'filetype': ['tex', 'plaintex']})
Still not working.
Sorry, this is a bug in lexima's initialization. I try to fix.
I have fixed. Please try again.
Adding the following to .vimrc now works:
call lexima#add_rule({'char': '$', 'input_after': '$', 'filetype': 'tex'}) call lexima#add_rule({'char': '$', 'at': '\%#\$', 'leave': 1, 'filetype': 'tex'}) call lexima#add_rule({'char': '', 'at': '\$\%#\$', 'delete': 1, 'filetype': 'tex'})
Thanks!
Is it possible to allow for adding custom characters to be autoclosed by lexima?
For example, I would like to add '$' to be autoclosed when working on latex files.