Thread: [Vim-latex-cvs] vimfiles/plugin imaps.vim,1.15,1.16
Brought to you by:
srinathava,
tmaas
From: <sri...@us...> - 2002-12-31 09:21:04
|
Update of /cvsroot/vim-latex/vimfiles/plugin In directory sc8-pr-cvs1:/tmp/cvs-serv20482 Modified Files: imaps.vim Log Message: 1. Problem: When the user tries to trigger an abbreviation near the eol, the marker string being too long triggers a line break. Therefore, just for the time being check to see if phs != phe, and if so, then use phs.phs as the marker (improbable string). We would like ultimately to completeley get over this hack and use movement instead. 2. Problem: The <C-K> map for jumping back was interfering with the dictionary completion mode of vim. Therefore change default mapping for jumping back to <S-C-J> instead of <C-K>. Ofcourse this makes it invisible to non-gui users (I think). 3. Tried to do the "right" thing for mapping. First provide a number of mappings using <plug>. These mappings call IMAP_Jumpfunc() in various ways. Various <plug> mappings for various modes have been provided. After this, we map the default keys to the <plug> mappings checking for hasmapto() each time. This provides for a robust and easy user customization. Initially, the user had to do something like: inoremap <C-J> <C-r>=IMAP_Jumpfunc('', 0)<CR> in his .vimrc to be able to override our mapping. Now he will do inoremap <C-J> <Plug>IMAP_JumpForward Doing this also has the advantage that changes in IMAP_Jumpfunc() will not affect the user customization. NOTE: This <plug> things were inspired by looking at the excellent cvscommand.vim plugin I've begun using... Index: imaps.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/plugin/imaps.vim,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** imaps.vim 30 Dec 2002 10:54:49 -0000 1.15 --- imaps.vim 31 Dec 2002 09:21:01 -0000 1.16 *************** *** 8,12 **** " while preserving filetype indentation. " ! " Last Change: Mon Dec 30 02:00 AM 2002 PST " " Documentation: {{{ --- 8,12 ---- " while preserving filetype indentation. " ! " Last Change: Tue Dec 31 01:00 AM 2002 PST " " Documentation: {{{ *************** *** 269,273 **** " A very rare string: Do not use any special characters here. This is used " for moving to the beginning of the inserted text. ! let marker = '<!---@#%_Start_Here_@#%----!>' let markerLength = strlen(marker) --- 269,280 ---- " A very rare string: Do not use any special characters here. This is used " for moving to the beginning of the inserted text. ! " When phs != phe, we are guarenteed that unless the user has done bad ! " things, phs.phs will never occur in the file. ! if phsUser != pheUser ! let marker = phsUser.phsUser ! else ! let marker = '<!---@#%_Start_Here_@#%----!>' ! endif ! call Tex_Debug('marker = '.marker) let markerLength = strlen(marker) *************** *** 404,421 **** " }}} " Maps for IMAP_Jumpfunc {{{ " map only if there is no mapping already. allows for user customization. ! if !hasmapto('IMAP_Jumpfunc') ! inoremap <C-J> <c-r>=IMAP_Jumpfunc('', 0)<CR> ! inoremap <C-K> <c-r>=IMAP_Jumpfunc('b', 0)<CR> ! nmap <C-J> i<C-J> ! nmap <C-K> i<C-K> ! if exists('g:Imap_StickyPlaceHolders') && g:Imap_StickyPlaceHolders ! vmap <C-J> <C-\><C-N>i<C-J> ! vmap <C-K> <C-\><C-N>i<C-K> ! else ! vmap <C-J> <Del>i<C-J> ! vmap <C-K> <Del>i<C-K> endif ! end " }}} --- 411,467 ---- " }}} " Maps for IMAP_Jumpfunc {{{ + " + " These mappings use <Plug> and thus provide for easy user customization. When + " the user wants to map some other key to jump forward, he can do for + " instance: + " nmap ,f <plug>IMAP_JumpForward + " etc. + + " jumping forward and back in insert mode. + imap <silent> <Plug>IMAP_JumpForward <c-r>=IMAP_Jumpfunc('', 0)<CR> + imap <silent> <Plug>IMAP_JumpBack <c-r>=IMAP_Jumpfunc('b', 0)<CR> + + " jumping in normal mode + nmap <silent> <Plug>IMAP_JumpForward i<c-r>=IMAP_Jumpfunc('', 0)<CR> + nmap <silent> <Plug>IMAP_JumpBack i<c-r>=IMAP_Jumpfunc('b', 0)<CR> + + " deleting the present selection and then jumping forward. + vmap <silent> <Plug>IMAP_DeleteAndJumpForward "_<Del>i<c-r>=IMAP_Jumpfunc('', 0)<CR> + vmap <silent> <Plug>IMAP_DeleteAndJumpBack "_<Del>i<c-r>=IMAP_Jumpfunc('b', 0)<CR> + + " jumping forward without deleting present selection. + vmap <silent> <Plug>IMAP_JumpForward <C-\><C-N>i<c-r>=IMAP_Jumpfunc('', 0)<CR> + vmap <silent> <Plug>IMAP_JumpBack <C-\><C-N>i<c-r>=IMAP_Jumpfunc('b', 0)<CR> + + " }}} + " Default maps for IMAP_Jumpfunc {{{ " map only if there is no mapping already. allows for user customization. ! if !hasmapto('<Plug>IMAP_JumpForward', 'i') ! imap <C-J> <Plug>IMAP_JumpForward ! endif ! if !hasmapto('<Plug>IMAP_JumpBack', 'i') ! imap <S-C-J> <Plug>IMAP_JumpBack ! endif ! if !hasmapto('<Plug>IMAP_JumpForward', 'n') ! nmap <C-J> <Plug>IMAP_JumpForward ! endif ! if !hasmapto('<Plug>IMAP_JumpBack', 'n') ! nmap <S-C-J> <Plug>IMAP_JumpBack ! endif ! if exists('g:Imap_StickyPlaceHolders') && g:Imap_StickyPlaceHolders ! if !hasmapto('<Plug>IMAP_JumpForward', 'v') ! vmap <C-J> <Plug>IMAP_JumpForward endif ! if !hasmapto('<Plug>IMAP_JumpBack', 'v') ! vmap <S-C-J> <Plug>IMAP_JumpBack ! endif ! else ! if !hasmapto('<Plug>IMAP_DeleteAndJumpForward', 'v') ! vmap <C-J> <Plug>IMAP_DeleteAndJumpForward ! endif ! if !hasmapto('<Plug>IMAP_DeleteAndJumpBack', 'v') ! vmap <S-C-J> <Plug>IMAP_DeleteAndJumpBack ! endif ! endif " }}} |
From: Benji F. <be...@me...> - 2002-12-31 16:07:07
|
sri...@us... wrote: > Update of /cvsroot/vim-latex/vimfiles/plugin > In directory sc8-pr-cvs1:/tmp/cvs-serv20482 > > Modified Files: > imaps.vim > Log Message: > 2. Problem: The <C-K> map for jumping back was interfering with the > dictionary completion mode of vim. Therefore change default mapping for > jumping back to <S-C-J> instead of <C-K>. Ofcourse this makes it > invisible to non-gui users (I think). Does this work for you? For me (gvim on Linux) <C-J> and <C-S-J> are the same. :nmap <C-J> :echo "foo"<CR> :nmap <S-C-J> :echo "bar"<CR> When I try <C-J> in Normal mode, it echoes "bar". > 3. Tried to do the "right" thing for mapping. First provide a number of > mappings using <plug>. These mappings call IMAP_Jumpfunc() in various > ways. Various <plug> mappings for various modes have been provided. > After this, we map the default keys to the <plug> mappings checking for > hasmapto() each time. This provides for a robust and easy user > customization. Initially, the user had to do something like: > inoremap <C-J> <C-r>=IMAP_Jumpfunc('', 0)<CR> > in his .vimrc to be able to override our mapping. Now he will do > inoremap <C-J> <Plug>IMAP_JumpForward > Doing this also has the advantage that changes in IMAP_Jumpfunc() will > not affect the user customization. > NOTE: This <plug> things were inspired by looking at the excellent > cvscommand.vim plugin I've begun using... This can go in texrc instead of vimrc, right? This is the system recommended in :help write-plugin . I have always used a simpler system: for most things, do not provide any key mapping by default. If the user specifies a key binding, use it (and display it in the menu). What I do not like about the current system is that it violates the principle of least surprise: if the user already has a use for <C-J>, then (s)he has to figure out how to disable this feature (or change the key binding). --Benji |
From: Srinath A. <sr...@fa...> - 2002-12-31 18:36:08
|
On Tue, 31 Dec 2002, Benji Fisher wrote: > Does this work for you? For me (gvim on Linux) <C-J> and <C-S-J> > are the same. > > :nmap <C-J> :echo "foo"<CR> > :nmap <S-C-J> :echo "bar"<CR> > Yes... I checked on my gvim/cygwin combination and it seems not to work. It does work on windows though... > What I do not like about the current system is that it violates > the principle of least surprise: if the user already has a use for > <C-J>, then (s)he has to figure out how to disable this feature (or > change the key binding). > Yes... You're right... Luc was complaining about this too... Okay. I shall disable the map for jumping back by default... I suppose this could go into the texrc as a commented line... Hmm... Thats an interesting idea. Maybe have commented lines like in the Makefile. "Uncomment if you want this behavior"... Maybe we should do this for all the <Alt-*> mappings? Most European users find the <M-[cbl]> mappings annoying because they are used to enter normal language characters... Unfortunately, most english language users will find it really useful to have something like this and for them, it is almost guarenteed that they are not doing anything with their <M-*> keys... Well I suppose we will have to at one point begin to do this for all mappings anyway. Just provide <plug>'s and then let the user customize... Srinath |