[Vim-latex-cvs] vimfiles/plugin imaps.vim,1.22,1.23
Brought to you by:
srinathava,
tmaas
From: <sri...@us...> - 2003-01-07 19:43:52
|
Update of /cvsroot/vim-latex/vimfiles/plugin In directory sc8-pr-cvs1:/tmp/cvs-serv3335 Modified Files: imaps.vim Log Message: - Description of arguments to IMAP_Jumpfunc(). - IMAP_Jumpfunc() is now able to handle <+placeholders withlinebreaks+> - Bug: If we were selecting in the backward direction, and we want to move backwards, then 2 <Plug>IMAP_JumpBack's are needed. i.e, if we have <+1+> <+2+> <+3+> and we do (with <C-k> mapped to <Plug>IMAP_JumpBack) <C-j><C-j><C-k>, from before <+1+>, then we remain in <+2+>. (Bug pointed out by LH) Cause: In visual mode, <Plug>IMAP_JumpBack deselects the text but remains at the end of the selection. (this is default vim behavior). Therefore searching back for the placeholder start character lands us up in the template. Solution: In visual mode, make <Plug>IMAP_JumpBack goto `< after deselecting text. This strategy also leads to considerable simplification at other places. Index: imaps.vim =================================================================== RCS file: /cvsroot/vim-latex/vimfiles/plugin/imaps.vim,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** imaps.vim 7 Jan 2003 18:27:47 -0000 1.22 --- imaps.vim 7 Jan 2003 19:43:41 -0000 1.23 *************** *** 339,343 **** " IMAP_Jumpfunc: takes user to next <+place-holder+> {{{ " Author: Luc Hermitte ! " function! IMAP_Jumpfunc(direction, inclusive) --- 339,355 ---- " IMAP_Jumpfunc: takes user to next <+place-holder+> {{{ " Author: Luc Hermitte ! " Arguments: ! " direction: flag for the search() function. If set to '', search forwards, ! " if 'b', then search backwards. See the {flags} argument of the ! " |search()| function for valid values. ! " inclusive: In vim, the search() function is 'exclusive', i.e we always goto ! " next cursor match even if there is a match starting from the ! " current cursor position. Setting this argument to 1 makes ! " IMAP_Jumpfunc() also respect a match at the current cursor ! " position. 'inclusive'ness is necessary for IMAP() because a ! " placeholder string can occur at the very beginning of a map which ! " we want to select. ! " We use a non-zero value only in special conditions. Most mappings ! " should use a zero value. function! IMAP_Jumpfunc(direction, inclusive) *************** *** 346,356 **** let pheUser = IMAP_GetPlaceHolderEnd() - let searchOpts = a:direction - " If the user has nowrapscan set, then do not make the search wrap around - " the end (or beginning) of the file. - if ! &wrapscan - let searchOpts = direction.'W' - endif - let searchString = '' " If this is not an inclusive search or if it is inclusive, but the --- 358,361 ---- *************** *** 358,371 **** " search for the placeholder characters. if !a:inclusive || strpart(getline('.'), col('.')-1) !~ '\V\^'.phsUser ! let searchString = '\V'.phsUser.'\.\{-}'.pheUser endif " If we didn't find any placeholders return quietly. ! if searchString != '' && !search(searchString, searchOpts) return '' endif - " At this point, we are at the beginning of a placeholder. - " Remember the position here. let position = line('.') . "normal! ".virtcol('.').'|' " Open any closed folds and make this part of the text visible. --- 363,374 ---- " search for the placeholder characters. if !a:inclusive || strpart(getline('.'), col('.')-1) !~ '\V\^'.phsUser ! let searchString = '\V'.phsUser.'\_.\{-}'.pheUser endif " If we didn't find any placeholders return quietly. ! if searchString != '' && !search(searchString, a:direction) return '' endif let position = line('.') . "normal! ".virtcol('.').'|' " Open any closed folds and make this part of the text visible. *************** *** 376,402 **** let template = \ matchstr(strpart(getline('.'), col('.')-1), ! \ '\V\^'.phsUser.'\zs\.\{-}\ze'.pheUser) let placeHolderEmpty = !strlen(template) ! " This movement command selects the placeholder text. In the forward mode, ! " we select left-right, otherwise right-left. ! if a:direction =~ 'b' ! " If we are going in the backward direction, make the selection from ! " right to left so that a backward search for phsUser doesnt get us ! " back to the same placeholder. ! let movement = "\<C-\>\<C-N>:".position."\<CR>" ! \ . "/\\V".pheUser."/e\<CR>" ! \ . "v?\\V".phsUser."?b\<CR>" ! else ! let movement = "\<C-\>\<C-N>:".position."\<CR>v/\\V".pheUser."/e\<CR>" ! endif if placeHolderEmpty && g:Imap_DeleteEmptyPlaceHolders " delete the empty placeholder into the blackhole. return movement."\"_c\<C-o>:".s:RemoveLastHistoryItem."\<CR>" - else return movement."\<C-\>\<C-N>:".s:RemoveLastHistoryItem."\<CR>gv\<C-g>" - endif --- 379,394 ---- let template = \ matchstr(strpart(getline('.'), col('.')-1), ! \ '\V\^'.phsUser.'\zs\.\{-}\ze\('.pheUser.'\|\$\)') let placeHolderEmpty = !strlen(template) ! " Select till the end placeholder character. ! let movement = "\<C-o>v/\\V".pheUser."/e\<CR>" + " Now either goto insert mode or select mode. if placeHolderEmpty && g:Imap_DeleteEmptyPlaceHolders " delete the empty placeholder into the blackhole. return movement."\"_c\<C-o>:".s:RemoveLastHistoryItem."\<CR>" else return movement."\<C-\>\<C-N>:".s:RemoveLastHistoryItem."\<CR>gv\<C-g>" endif *************** *** 426,430 **** " 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> " }}} --- 418,422 ---- " 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> " }}} |