71 Commits

Author SHA1 Message Date
Gerd Wachsmuth 84a9039aa6 Use startinsert instead of feedkeys()
With feedkeys, the "_c was delayed until the very end of an active
mapping. Now, startinsert is issued immediately and the IMAP_JumpFunc
leaves in insertmode (if there was an empty placeholder).
2017-02-11 22:27:56 +01:00
Gerd Wachsmuth 15262af05f Use function! 2017-02-11 22:27:40 +01:00
Gerd Wachsmuth 15c93a4a84 Move functions from imaps.vim to main.vim
These two functions (along with two helper functions) are quite
unrelated to the functionality of imaps.vim.
2017-02-10 22:41:19 +01:00
Gerd Wachsmuth 6f98bde52a Make ft-IMAPs <buffer>-local
Now, all the IMAPs with ft='tex' will only appear as imaps in buffers
with ft=tex.
2017-02-08 21:09:10 +01:00
Gerd Wachsmuth 8cb9708aab Change IMAP_JumpFunc to a 'normal-mode function'
Up to now, IMAP_JumpFunc has to be called from insert mode. This
rendered the code in this function a little bit complicated. Now, it is
simpler to understand and to modify.
2017-01-28 11:21:26 +01:00
Gerd Wachsmuth 0e832ae9f3 Add IUNMAP function. 2016-12-28 21:57:54 +01:00
Gerd Wachsmuth 249d8397b4 Fix bug in IMAP matchings 2016-12-28 21:53:30 +01:00
Gerd Wachsmuth 8e28c3c304 Remove encoding and decoding of text.
In my opinion, this works now without the decoding. I have tested the
issue with the matching of "\xab" with itself, and it seems to be fine
in recent versions of Vim. (However, I did not find a clue in the change
logs of Vim concerning this issue)
2016-10-08 23:45:06 +02:00
Gerd Wachsmuth f138a527a2 Allow for multibyte placeholders
When selecting the placeholders, we have to use virtcol() instead of
col(), since bytes != columns.

Will this be the comeback of « and »?
2016-10-08 23:42:51 +02:00
Gerd Wachsmuth ba140b1bd2 Use maparg to check for abbreviations
Here, we utilize the 'abbr' argument in maparg,
which was introduced in Vim 7.
2016-10-08 23:23:57 +02:00
Gerd Wachsmuth b59d55ba9d Remove comment concering "Snip" 2016-10-08 21:55:12 +02:00
Gerd Wachsmuth dcee3581d7 Remove two superfluous functions 2016-10-07 12:05:09 +02:00
Gerd Wachsmuth b0a12cda0b Add debug function IMAP_list_all
Also fix two little bugs:
* Do not add lhs to s:LHS_... if it is already in there
* Use strtrans() in IMAP_list
2016-10-07 12:00:44 +02:00
Gerd Wachsmuth 6b8205e20e Replace MultiByteStrpart by specialized functions
We needed MultiByteStrpart for two reasons:
* remove last char
* return last char
This is now handled by two specialized functions.
2016-10-07 10:26:10 +02:00
Gerd Wachsmuth 4239843a55 Change logic for backspaces
Since we also add the mapped character (a:char), we have to erase it.
Hence, we do not need the '-1' and add another "\<bs>" later on.
2016-10-07 10:15:52 +02:00
Gerd Wachsmuth 1314b24df3 Use \%( \) in plugin/imaps.vim
Might be slightly faster than \( \)
2016-10-07 10:14:45 +02:00
Gerd Wachsmuth 4586e2210f Add gates to suppress latex-suite if needed.
This is usefull if latex-suite is installed system-wide but you do not
want to use it.
2016-10-05 10:52:14 +02:00
Gerd Wachsmuth ee2822394c Fix issue in LookupCharacter
In insert mode, <c-v>O will let you insert ascii keycodes as octal
numbers. Hence, an 'O' must not be preceeded by <c-v>. However, <c-v> is
necessary, if a:char is <c-\>.

Fix #59
2016-07-24 12:20:13 +02:00
Yuchen Ding c7aa5fa063 Fix issue in LookupCharacter
If a:char is a special character (e.g., <c-\>), it could interact with the following <c-g>.
Solution: Insert a:char literally.
2016-06-11 23:10:07 +02:00
Gerd Wachsmuth 5ab742d548 Fix bug with :iab
See http://vi.stackexchange.com/questions/2245/strange-behaviour-of-abbreviations-triggered-with-shiftenter-in-gvimvim-latex.
2016-04-25 22:55:36 +02:00
Gerd Wachsmuth 63b02f05ce New option: g:Imap_GoToSelectMode
This can be used to fix #47.
2016-04-25 22:50:59 +02:00
Gerd Wachsmuth fa6192981e Do not turn on highlighting in IMAP_Jumpfunc.
IMAP_Jumpfunc does not use the search prompt anymore. Thus, it will not have any effect on search highlighting.
2016-04-25 22:50:58 +02:00
Daeyun Shin 392577fc20 Fix: allow function overloading - Add the missing function qualifier (!) to indicate that MultiByteStrpart and MultiByteStrlen can be safely overloaded. See https://github.com/vim-latex/vim-latex/issues/5 2014-11-23 10:36:47 +01:00
LuX 02cce04263 imaps.vim: Add multibyte LHS support
- Add s:MultiByteStrlen() and s:MultiByteStrpart()
- Allow for example IMAP chaining as follows:
call IMAP("\\subset", "⊂", "")
call IMAP("⊂eq", "⊆", "")

References:
https://sourceforge.net/p/vim-latex/patches/5/
2014-11-15 19:08:36 +01:00
TODA Shuta 0ced0c9571 Fix some mappings to avoid unexpected recursive expansion. 2014-11-15 17:31:14 +01:00
Till Maas 3e7695b366 Restore registers with setreg()
Do not use "let @a = _a" to restore registers, since this adds an extra line
feed character to the register.

References:
- http://stackoverflow.com/questions/26896399/why-does-let-modify-the-value-it-assigns
- https://bugzilla.redhat.com/show_bug.cgi?id=1163518

Patch idea by Daniel Wagner <me@dmwit.com>
2014-11-15 16:34:02 +01:00
Till Maas dd2e3daf1e remove remaining SVN/CVS keywords 2014-11-15 15:23:57 +01:00
Michael Ekstrand 1a10ee7cc9 Use noremap for IMAP mappings
The IMAP mappings used plain [inv]map instead of the noremap
versions.  This causes conflicts with other plugins.
2014-05-12 13:31:03 -05:00
Bodo Graumann ce16347c36 Allow to undo IMAP substitution 2012-11-01 00:19:38 +01:00
Philipp Hartwig 8d8d1f4423 imaps: make VEnclose work when ignorecase is set 2011-02-14 20:57:42 +01:00
Till Maas e2f07b8792 remove most svn/CVS keywords 2010-11-12 22:12:38 +01:00
Srinath Avadhanula 059382b7db New: Used one of the advantages of using svn. Liberally used the 'prop*'
commands to do the following:
     1. change the EOL style of all vim files to be just LF.
     2. changed the mime-type of all files to text/plain
     3. removed the executable flag on all files.
     This should hopefully make the repo look better on all platforms etc.
2006-03-20 09:45:45 +00:00
Srinath Avadhanula 3fff75c2a2 Bug: If there is an abbreviation like this:
:iab zzz whatever
     then typing 'z<space>' triggers the abbreviation in the presence of
     latex-suite. (Cristian Rigamonti)
Why: The reg-exp used to find out if a iab existed was faulty.
Fix: Fix the regexp to use an exact match of the previous word.
2006-03-19 04:29:47 +00:00
Srinath Avadhanula 2de1a71275 Bug: Typing
>>> \begin{array}
     >>>    \end{}
     results in
     >>> \begin{array}
     >>> \end{<++>}
     with the cursor at the end (Berta Milan)
Why: When the indentation of a line changes while typing the text returned
     by IMAP_PutTextWithMovement, then IMAP_Mark('go') does not go to the
     same location as set by IMAP_Mark('set'). This causes the cursor to be
     located not before the first placeholder causing the first
     placeholder to be "missed".
Fix: Check to see if the indentation of the line remembered by
     IMAP_Mark('set') has changed and if so, move a little to the left or
     right to adjust for the indentation changing.
2004-05-30 07:35:40 +00:00
Srinath Avadhanula 88d15e913d Bug: when 'ignorecase' is set, then typing 'etB' triggers an error.
Why: With 'ignorecase' set, 'etB' matches 'ETB', therefore, LookupCharacter
     assumes that a map exists for 'etB' and tries to find the value of
     s:Map_Tex_etB which doesn't exist.
Fix: Force matching case with the \C pattern.
2004-05-04 20:50:11 +00:00
Srinath Avadhanula 8911aa61ca Meta-bug! A bug in the debugging function. 2003-12-04 00:06:06 +00:00
Srinath Avadhanula 7401953921 Bug: When &enc==utf8 and g:Imap_PlaceHolder* settings are not lower-ascii,
then we would get an error when we used any of the IMAP functions!
Why: A silly little bug. An extra quote
2003-11-26 05:45:46 +00:00
Srinath Avadhanula 86fb6cddeb New: the g:Imap_FreezeImap function temporarily pauses any macro expansion. 2003-11-14 10:37:56 +00:00
Srinath Avadhanula 6411382543 Bug: Sometimes a Tex_LastSearchPattern not found error is generated (Eugene
Minkovskii)
2003-11-13 08:53:43 +00:00
Srinath Avadhanula 7d2bd15843 Bug: @/ would sometimes change from its previous value when using
IMAP_Jumpfunc().
Why: s:RemoveLastHistoryItem sets @/ to the last search item in the @/
     history, but @/ is not necessarily always the last item in the @/
     history.
Fix: Remember @/ in Tex_LastSearchPattern and then restore it.
2003-09-06 20:07:25 +00:00
Srinath Avadhanula 3b3fa0ceb1 Bug: IMAP_Jumpfunc() and VEnclose() do not work with &selection =
'exclusive' (Jannie Hofmeyr, Pierre Antoine Champin)
Fix: Select one more character in 'exclusive' mode. (suggested by Pierre
     Antoine Champin).
2003-06-19 01:21:33 +00:00
Srinath Avadhanula 4eac530584 Bug: If an abbreviatin contains \ or " characters, then the abbreviation is
not expanded properly. (D. MacAlpine)
Fix: Those characters need to be escaped before the quoting.
2003-03-25 19:11:40 +00:00
Srinath Avadhanula 66b86d3fbc Bug: Incorrect detection of abbreviations. If there was (were)
abbreviations starting with the letter 'a', then typing 'a<space>'
     would trigger an expansion.
Cause: The :iab command also echoes for partial completions.
Solution: Check more thoroughly whether a word is an abbreviation LHS or
          not.
2003-03-25 08:20:11 +00:00
Srinath Avadhanula 7b5feffb4d Bug: iabs break when latex-suite is triggered.
(Preben Randhol, Sanip P Deshmukh)
Cause: If a mapping ends in a letter (say '\'), then abbreviations are not
    triggered by that letter. For example, if we have
        imap \ <C-r>='\'<CR>
        iab 12 twelve
    Then typing 12\ doesn't expand to twelve\.
    (Strangely enough "imap \ ?" doesn't have this problem and we get
    twelve?. Vim bug?)
    This problem is aggravated by the fact that latex-suite "protects"
    most letters to avoid expansions such as ``2 -> `\sqrt{}
Solution: After checking for mappings ending in a letter, if that letter is
    not in 'iskeyword', then also check whether the previous word has
    an abbreviation. Since vim does not have the equivalent of
    mapcheck() for abbreviations, this is complicated (maybe even hacky).
2003-02-05 23:29:04 +00:00
Srinath Avadhanula fae6eb53cf - Bug: imaps do not work on default win32 installations of vim because
:behave mswin
       is set, which in turn sets &selection=inclusive. This makes
       IMAP_Jumpfunc() skip selecting the last character of
       Imap_PlaceHolderEnd. (Sumit Bhardwaj)
  Solution: Temporarily set &selection = exclusive in IMAP_Jumpfunc().
2003-02-05 04:12:28 +00:00
Srinath Avadhanula 9186e9ff31 . Adding in the header instead of the Last Change: Wed Jan 08 04:00 PM 2003 PST
revision tag is necessary in a file, imo.
  NOTE: This wont cause spurious revisions, problems in merging etc.
2003-01-09 00:57:58 +00:00
Srinath Avadhanula ae67765d27 - always use the blackhole register to do yanks/substitutions etc,
otherwise the user's unnamed register gets eaten up.
2003-01-08 23:50:12 +00:00
Srinath Avadhanula 4e55f84086 - removing an unnecessary line from a previous version. 2003-01-07 20:53:38 +00:00
Srinath Avadhanula dadc582f31 - 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.
2003-01-07 19:43:41 +00:00
Benji Fisher e3c015dde6 * Improve s:PutTextWithMovement() by using a new helper function, IMAP_Mark(),
to position the cursor instead of adding a marker string and searching for it.
The marker would cause serious trouble if it occurred anywhere in the inserted
text, and minor trouble if it was too long and caused an unwanted line break.

* Fix a bug (mea culpa) in s:LookupCharacter() and IMAP_list().  If there was
a global map for "foo" and a local (filetype) map for "bozo" then these
functions would look at the last character, "o", see that there were local
maps ending in "o", and only look for local maps.
2003-01-07 18:27:47 +00:00