Re: [Vim-latex-cvs] vimfiles/plugin imaps.vim,1.14,1.15
Brought to you by:
srinathava,
tmaas
From: Benji F. <be...@me...> - 2003-01-06 15:41:10
|
Benji Fisher wrote: > Srinath Avadhanula wrote: > >> On Mon, 30 Dec 2002, Benji Fisher wrote: >> >> Yes. Positioning using movement is the best... The problem I ran across >> was that if you do something like >> >> :set encoding=utf8 >> :let bar = "?" >> (where the ? character is typed using <C-v><<) >> :echo strlen(bar) >> 2 >> >> Can this problem be taken care of using the change in encoding etc? >> Hmm... I see that >> :echo strlen(iconv(bar, &encoding, 'latin1')) >> 1 >> :echo strlen(substitute(bar, '.', 'x', 'g')) >> 1 >> >> So those two methods might work... It will be a definite improvement >> over the current "hack". Well, the idea is for :call IMAP(fb, "foo<++>bar") to return something like "foobar\<Esc>3\<bs>a". That should work for this example, but what if "bar" is replaced by something with a bunch of "\n" characters in it? One of the advantages of imap.vim--it respects auto-indent--makes it (nearly) impossible for us to compute how many spaces to back up. Back to the drawing board! My latest idea is to break up the RHS (in the example above) into "foo" and "" and "bar" and then to have IMAP_PutTextWithMovement() return something like "foo\<Esc>:call IMAP_YAHF(0)\<CR><++>bar\<Esc>:call IMAP_YAHF(1)\<CR>" and then call IMAP_Jumpfunc(). I will choose a more descriptive name than YAHF (Yet Another Helper Function), which will store the line and column number in a script-local variable (when called with argument 0) and then position the cursor there (when called with argument 1). Does anyone see any problems with this approach? Any objections (other than the profusion of helper functions)? --Benji |