Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Friday, October 16, 2026

Diff for vimconfig/vim/plugin/imaps.vim between version 1.2 and 1.3

version 1.2, 2002/04/06 18:01:39 version 1.3, 2002/11/18 09:36:17
Line 47 
Line 47 
 "  "
 " Consider a working example:  " Consider a working example:
 "  "
 " let s:tex_bit  = "\\begin{itemize}\<cr>\\item ä\<cr>\\end{itemize}"  " let s:tex_bit  = "\\begin{itemize}\<cr>\\item ää\<cr>\\end{itemize}"
 "  "
 " This effectively sets up the map  " This effectively sets up the map
 "  "
Line 60 
Line 60 
 " \item *  " \item *
 " \end{itemize}  " \end{itemize}
 "  "
 " where * shows the cursor position. The special character ä (typed as  " where * shows the cursor position. The special characters "ää" (typed as
 " CTRL-K + a + :) decides the cursor placement after the expansion. If there  " CTRL-K + a + :) decides the cursor placement after the expansion. If there
 " is no ä, then the cursor is left at the end.  " is no "ää", then the cursor is left at the end.
 "  "
 " however, unlike in mappings, it is not necessary to enter the keys  " however, unlike in mappings, it is not necessary to enter the keys
 " b,i,t,<leader> in quick succession. this works by just mapping the last  " b,i,t,<leader> in quick succession. this works by just mapping the last
Line 70 
Line 70 
 " check is then made to see if the characters entered before match the total  " check is then made to see if the characters entered before match the total
 " LHS of the required mapping.  " LHS of the required mapping.
 "  "
   " NOTE: some functions may confuse user. Therefore if exists variable
   " "g:disable_imap" and is set to ":let g:disable_imap=1", all functions
   " returns ASAP. This feature was added by Lubomir Host <rajo AT host.sk>
   "
 " NOTE: There are other plugins out there which do the same thing. For  " NOTE: There are other plugins out there which do the same thing. For
 " example, Dr. Chip's Cabbr script at  " example, Dr. Chip's Cabbr script at
 "    http://users.erols.com/astronaut/vim/index.html#CAbbrv  "    http://users.erols.com/astronaut/vim/index.html#CAbbrv
Line 106 
Line 110 
 "       the previously typed characters and erased and the right hand side is  "       the previously typed characters and erased and the right hand side is
 "       inserted.  "       inserted.
 function! IMAP(lhs, rhs, ft)  function! IMAP(lhs, rhs, ft)
           if exists("g:disable_imap")
                   if g:disable_imap == 1
                           return
                   endif
           endif
         let lastLHSChar = a:lhs[strlen(a:lhs)-1]          let lastLHSChar = a:lhs[strlen(a:lhs)-1]
         " s:charLens_<ft>_<char> contains the lengths of the left hand sides of          " s:charLens_<ft>_<char> contains the lengths of the left hand sides of
         " the various mappings for filetype <ft> which end in <char>. its a comma          " the various mappings for filetype <ft> which end in <char>. its a comma
Line 173  endfunction
Line 182  endfunction
 " character and then if a possible match exists, ereases the left-hand side  " character and then if a possible match exists, ereases the left-hand side
 " and inserts the right hand side instead.  " and inserts the right hand side instead.
 silent! function! <SID>LookupCharacter(char)  silent! function! <SID>LookupCharacter(char)
           if exists("g:disable_imap")
                   if g:disable_imap == 1
                           echo "LookupCharacter(\"" . a:char . "\") - disabled (g:disabled=1)"
                           " here we must return parameter
                           return a:char
                   endif
           endif
           echo "LookupCharacter(\"" . a:char . "\") - enabled (g:disabled=0)"
         let charHash = char2nr(a:char)          let charHash = char2nr(a:char)
   
         if !exists('s:charLens_'.&ft.'_'.charHash)          if !exists('s:charLens_'.&ft.'_'.charHash)
Line 232  endfunction
Line 249  endfunction
 " IMAP_PutTextWithMovement: appends movement commands to a text  {{{  " IMAP_PutTextWithMovement: appends movement commands to a text  {{{
 "               This enables which cursor placement.  "               This enables which cursor placement.
 function! IMAP_PutTextWithMovement(text)  function! IMAP_PutTextWithMovement(text)
           if exists("g:disable_imap")
                   if g:disable_imap == 1
                           return
                   endif
           endif
   
         " if the text contains a ä or a «label», then get to the first one of          " if the text contains a ä or a «label», then get to the first one of
         " those.          " those.
         let fc = match(a:text, 'ä\|«[^»]*»')          let fc = match(a:text, 'ää\|«[^»]*»')
         if fc < 0          if fc < 0
                 let initial = ""                  let initial = ""
                 let movement = ""                  let movement = ""
Line 242  function! IMAP_PutTextWithMovement(text)
Line 265  function! IMAP_PutTextWithMovement(text)
         " search will do...          " search will do...
         elseif fc == 0          elseif fc == 0
                 let initial = ""                  let initial = ""
                 let movement = "\<esc>?ä\<cr>:call SAImaps_RemoveLastHistoryItem()\<cr>s"                  let movement = "\<esc>?ää\<cr>:call SAImaps_RemoveLastHistoryItem()\<cr>s"
         " however, if its somewhere in the middle, then we need to go back to the          " however, if its somewhere in the middle, then we need to go back to the
         " beginning of the pattern and then do a forward lookup from that point.          " beginning of the pattern and then do a forward lookup from that point.
         else          else
Line 252  function! IMAP_PutTextWithMovement(text)
Line 275  function! IMAP_PutTextWithMovement(text)
                 " delete that dummy part. we are left at the very beginning.                  " delete that dummy part. we are left at the very beginning.
                 let movement = "\<esc>?¡¡Start!!\<cr>v8l\"_x"                  let movement = "\<esc>?¡¡Start!!\<cr>v8l\"_x"
                 " now proceed with the forward search for cursor placement                  " now proceed with the forward search for cursor placement
                 let movement = movement."/ä\\|«[^»]*»\<cr>"                  let movement = movement."/ää\\|«[^»]*»\<cr>"
                 " we needed 2 searches to get here. remove them from the search                  " we needed 2 searches to get here. remove them from the search
                 " history.                  " history.
                 let movement = movement.":call SAImaps_RemoveLastHistoryItem()\<cr>"                  let movement = movement.":call SAImaps_RemoveLastHistoryItem()\<cr>"
                 let movement = movement.":call SAImaps_RemoveLastHistoryItem()\<cr>"                  let movement = movement.":call SAImaps_RemoveLastHistoryItem()\<cr>"
                 " if its a ä or «», then just delete it                  " if its a ä or «», then just delete it
                 if a:text[fc] == 'ä'                  if strpart(a:text, fc, 2) == 'ää'
                         let movement = movement."\"_s"                          let movement = movement."\"_2s"
                 elseif strpart(a:text, fc, 2) == '«»'                  elseif strpart(a:text, fc, 2) == '«»'
                         let movement = movement."\"_2s"                          let movement = movement."\"_2s"
                 " otherwise enter select mode...                  " otherwise enter select mode...
Line 273  endfunction
Line 296  endfunction
 " }}}  " }}}
 " Strntok: extract the n^th token from a list {{{  " Strntok: extract the n^th token from a list {{{
 " example: Strntok('1,23,3', ',', 2) = 23  " example: Strntok('1,23,3', ',', 2) = 23
 fun! <SID>Strntok(s, tok, n)  function! <SID>Strntok(s, tok, n)
           if exists("g:disable_imap")
                   if g:disable_imap == 1
                           return
                   endif
           endif
         return matchstr( a:s.a:tok[0], '\v(\zs([^'.a:tok.']*)\ze['.a:tok.']){'.a:n.'}')          return matchstr( a:s.a:tok[0], '\v(\zs([^'.a:tok.']*)\ze['.a:tok.']){'.a:n.'}')
 endfun  endfunction
   
 " }}}  " }}}
 " extract the leader character. the mappings need to go *after* the functio  " extract the leader character. the mappings need to go *after* the functio
Line 291  call IMAP ('latexs'.s:ml, "http://roboti
Line 319  call IMAP ('latexs'.s:ml, "http://roboti
 call IMAP ('homep'.s:ml, "http://robotics.eecs.berkeley.edu/~srinath", '')  call IMAP ('homep'.s:ml, "http://robotics.eecs.berkeley.edu/~srinath", '')
 " End general purpose mappings }}}  " End general purpose mappings }}}
 " Vim Mappings {{{  " Vim Mappings {{{
 call IMAP ('while'.s:ml, "let i = ä\<cr>while i <= \<cr>\<cr>\tlet i = i + 1\<cr>\<bs>endwhile", 'vim')  call IMAP ('while'.s:ml, "let i = ää\<cr>while i <= \<cr>\<cr>\tlet i = i + 1\<cr>\<bs>endwhile", 'vim')
 call IMAP ('fdesc'.s:ml, "\"Description: ", 'vim')  call IMAP ('fdesc'.s:ml, "\"Description: ", 'vim')
 " end vim mappings }}}  " end vim mappings }}}
   
Line 304  call IMAP ('fdesc'.s:ml, "\"Description:
Line 332  call IMAP ('fdesc'.s:ml, "\"Description:
 "   pleasing alternative instead of hardcoding a length.  "   pleasing alternative instead of hardcoding a length.
 "-------------------------------------%<-------------------------------------  "-------------------------------------%<-------------------------------------
 function! <SID>Snip() range  function! <SID>Snip() range
           if exists("g:disable_imap")
                   if g:disable_imap == 1
                           return
                   endif
           endif
         let i = a:firstline          let i = a:firstline
         let maxlen = -2          let maxlen = -2
         " find out the maximum virtual length of each line.          " find out the maximum virtual length of each line.
Line 330  com! -nargs=0 -range Snip :<line1>,<line
Line 363  com! -nargs=0 -range Snip :<line1>,<line
 " Description: This function needs to be globally visible because its  " Description: This function needs to be globally visible because its
 "              called from outside the script during expansion.  "              called from outside the script during expansion.
 function! SAImaps_RemoveLastHistoryItem()  function! SAImaps_RemoveLastHistoryItem()
   call histdel("/", -1)          if exists("g:disable_imap")
   let @/ = histget("/", -1)                  if g:disable_imap == 1
                           return
                   endif
           endif
           call histdel("/", -1)
           let @/ = histget("/", -1)
 endfunction  endfunction
 " }}}  " }}}
 " IMAP_Jumpfunc: takes user to next «place-holder» {{{  " IMAP_Jumpfunc: takes user to next «place-holder» {{{
Line 339  endfunction
Line 377  endfunction
 "                taken from mu-template.vim by him This idea is originally  "                taken from mu-template.vim by him This idea is originally
 "                from Stephen Riehm's bracketing system.  "                from Stephen Riehm's bracketing system.
 function! IMAP_Jumpfunc()  function! IMAP_Jumpfunc()
           if exists("g:disable_imap")
                   if g:disable_imap == 1
                           return
                   endif
           endif
         if !search('«.\{-}»','W') "no more marks          if !search('«.\{-}»','W') "no more marks
                 return "\<CR>"                  return "\<CR>"
         else          else
Line 351  function! IMAP_Jumpfunc()
Line 394  function! IMAP_Jumpfunc()
 endfunction  endfunction
 " map only if there is no mapping already. allows for user customization.  " map only if there is no mapping already. allows for user customization.
 if !hasmapto('IMAP_Jumpfunc')  if !hasmapto('IMAP_Jumpfunc')
     inoremap <C-J> <c-r>=IMAP_Jumpfunc()<CR>          inoremap <C-J> <c-r>=IMAP_Jumpfunc()<CR>
     nmap <C-J> i<C-J>          nmap <C-J> i<C-J>
 end  end
 " }}}  " }}}
   

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

Platon Group <platon@platon.org> http://platon.org/
Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top