[Vim-latex-cvs] vimfiles/ftplugin/tex brackets.vim,1.1,1.2
Brought to you by:
srinathava,
tmaas
|
From: <sri...@us...> - 2002-12-07 01:09:07
|
Update of /cvsroot/vim-latex/vimfiles/ftplugin/tex
In directory sc8-pr-cvs1:/tmp/cvs-serv14707
Modified Files:
brackets.vim
Log Message:
Marco Aurelio Valtas Cunha writes:
I'm using the latex-suite to write in Portuguese. Portuguese often has
caracters like 'ã' but latex-suite maps this to \cite{}. After look
around I couldn't find a simple way to 1) remap or 2) disable.
Solution:
Provide new globally visible functions Tex_MathBF, Tex_MathCal and
Tex_LeftRight. Use mapcheck() to check whether a map exists for these
functions before mapping the alt keys to trigger them. This enables people
who might need the alt keys for other uses to utilize this behavior and
keep the original behavior of their alt keys.
Example:
In order to use some other key, (say <CTRL-c>) to use Tex_MathCal(), do the
following
inoremap <buffer> <silent> <C-c> <C-r>=Tex_MathCal()<CR>
If you do not want to use this functionality at all, do something like:
inoremap <buffer> <silent> <plug>1 <C-r>=Tex_MathCal()<CR>
This will never trigger the map.
Index: brackets.vim
===================================================================
RCS file: /cvsroot/vim-latex/vimfiles/ftplugin/tex/brackets.vim,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** brackets.vim 17 Nov 2002 03:45:39 -0000 1.1
--- brackets.vim 7 Dec 2002 01:09:03 -0000 1.2
***************
*** 2,7 ****
" Author: Carl Mueller
" (incorporated into latex-suite by Srinath Avadhanula)
! " Last Change: Sat Nov 16 06:00 PM 2002 PST
" Desciption:
" ==============================================================================
--- 2,37 ----
" Author: Carl Mueller
" (incorporated into latex-suite by Srinath Avadhanula)
! " Last Change: Fri Dec 06 05:00 PM 2002 PST
" Desciption:
+ " This ftplugin provides the following maps:
+ " . <M-b> encloses the previous character in \mathbf{}
+ " . <M-c> is polymorphic as follows:
+ " Insert mode:
+ " 1. If the previous character is a letter or number, then capitalize it and
+ " enclose it in \mathcal{}
+ " 2. otherwise insert \cite{}
+ " Visual Mode:
+ " 1. Enclose selection in \mathcal{}
+ " . <M-l> is also polymorphic as follows:
+ " If the character before typing <M-l> is one of '([{|<q', then do the
+ " following:
+ " 1. (<M-l> \left(\right
+ " similarly for [, |
+ " {<M-l> \left\{\right\}
+ " 2. <<M-l> \langle\rangle
+ " 3. q<M-l> \lefteqn{}
+ " otherwise insert \label{}
+ "
+ " These functions make it extremeley easy to do all the \left \right stuff in
+ " latex.
+ "
+ " NOTE: The insert mode maps are created only if maps are no maps already to
+ " the relevant functions Tex_MathBF, Tex_MathCal and Tex_LeftRight. This is to
+ " enable people who might need the alt keys for typing to use some other
+ " keypress to trigger the same behavior. In order to use some other key, (say
+ " <C-c>) to use Tex_MathCal(), do the following
+ "
+ " inoremap <buffer> <silent> <C-c> <C-r>=Tex_MathCal()<CR>
+ "
" ==============================================================================
***************
*** 12,20 ****
" Visual Mode:
" Encloses the selected portion in \mathbf{}
! inoremap <buffer> <silent> <M-b> <Left>\mathbf{<Right>}<Esc>hvUla
vnoremap <buffer> <silent> <M-b> <C-C>`>a}<Esc>`<i\mathbf{<Esc>
" }}}
" ==============================================================================
! " MathCal: Mapping <M-c> to insert \mathcal{} or \cite{} {{{
" Insert Mode:
" 1. If the previous character is a letter or number, then capitalize it and
--- 42,61 ----
" Visual Mode:
" Encloses the selected portion in \mathbf{}
!
! if !hasmapto('Tex_MathBF')
! inoremap <buffer> <silent> <M-b> <C-r>=Tex_MathBF()<CR>
! endif
!
! " Tex_MathBF: encloses te previous letter or number in \mathbf{} {{{
! " Description:
! function! Tex_MathBF()
! return "\<Left>\\mathbf{\<Right>}\<Esc>hvUla"
! endfunction " }}}
!
vnoremap <buffer> <silent> <M-b> <C-C>`>a}<Esc>`<i\mathbf{<Esc>
" }}}
+
" ==============================================================================
! " Tex_MathCal: Mapping <M-c> to insert \mathcal{} or \cite{} {{{
" Insert Mode:
" 1. If the previous character is a letter or number, then capitalize it and
***************
*** 23,30 ****
" Visual Mode:
" 1. Enclose selection in \mathcal{}
! inoremap <buffer> <silent> <M-c> <C-R>=<SID>MathCal()<CR>
! if !exists('*s:MathCal')
! function! s:MathCal()
let line = getline(line("."))
let char = line[col(".")-2]
--- 64,74 ----
" Visual Mode:
" 1. Enclose selection in \mathcal{}
! if !hasmapto('Tex_MathCal') && mapcheck('<M-c>') == ''
! inoremap <buffer> <silent> <M-c> <C-R>=Tex_MathCal()<CR>
! endif
! if !exists('*Tex_MathCal')
!
! function! Tex_MathCal()
let line = getline(line("."))
let char = line[col(".")-2]
***************
*** 36,39 ****
--- 80,84 ----
endif
endfunction
+
endif
***************
*** 41,54 ****
" }}}
" ==============================================================================
" LeftRight: Function for inserting \left and \right in front of bracket chars
" in various ways using <M-l>. If not possible, insert \label{«»}«»
" {{{
"
! inoremap <buffer> <silent> <M-l> <C-r>=<SID>LeftRight()<CR>
! nnoremap <buffer> <silent> <M-l> :call <SID>PutLeftRight()<CR>
if !exists('*s:LeftRight')
! " LeftRight: maps <M-l> in insert mode. {{{
" This is a polymorphic function, which maps the behaviour of <M-l> in the
" following way:
--- 86,105 ----
" }}}
+
" ==============================================================================
" LeftRight: Function for inserting \left and \right in front of bracket chars
" in various ways using <M-l>. If not possible, insert \label{«»}«»
+ " ==============================================================================
" {{{
"
! if !hasmapto('Tex_LeftRight')
! inoremap <buffer> <silent> <M-l> <C-r>=Tex_LeftRight()<CR>
! endif
! if !hasmapto('Tex_PutLeftRight')
! nnoremap <buffer> <silent> <M-l> :call <SID>PutLeftRight()<CR>
! endif
if !exists('*s:LeftRight')
! " Tex_LeftRight: maps <M-l> in insert mode. {{{
" This is a polymorphic function, which maps the behaviour of <M-l> in the
" following way:
***************
*** 61,65 ****
" 3. q<M-l> \lefteqn{«»}«»
" otherwise insert \label{«»}«»
! function! s:LeftRight()
let line = getline(line("."))
let char = line[col(".")-2]
--- 112,116 ----
" 3. q<M-l> \lefteqn{«»}«»
" otherwise insert \label{«»}«»
! function! Tex_LeftRight()
let line = getline(line("."))
let char = line[col(".")-2]
***************
*** 82,88 ****
endif
endfunction " }}}
! " PutLeftRight: maps <M-l> in normal mode {{{
" Put \left...\right in front of the matched brackets.
! function! s:PutLeftRight()
let previous = getline(line("."))[col(".") - 2]
let char = getline(line("."))[col(".") - 1]
--- 133,139 ----
endif
endfunction " }}}
! " Tex_PutLeftRight: maps <M-l> in normal mode {{{
" Put \left...\right in front of the matched brackets.
! function! Tex_PutLeftRight()
let previous = getline(line("."))[col(".") - 2]
let char = getline(line("."))[col(".") - 1]
***************
*** 102,106 ****
" }}}
- " ==============================================================================
" vim:fdm=marker
--- 153,156 ----
|