Kana Natsuno schrieb: > Hello, Vimmers. > I noticed that abbreviations are not expanded by a character > which are generated by key mappings which cannot be remapped.
Once I noticed this too: http://groups.google.com/group/vim_dev/browse_thread/thread/4bcb7041761eea15/82671547b1cbcc63?#82671547b1cbcc63 > There is no description on this behavior in :help as far as > I read. So that it should be noted in :help Abbreviations. > > Anyway, I wish there were a pseudo key to expand abbreviation > even if it is generated by unremappable key mappings. This key exists, it is <C-]>: :h c_Ctrl-] :h i_Ctrl-] But, the current implementation is not very useful: - If <C-]> cannot expand an abbreviation, it inserts itself (it should never insert itself). - <C-]> on the {rhs} of an :inoremap command always inserts itself (it should always try to expand an abbrev). > For example, some users use the following key mapping to insert a line > break even if ins-completion-menu is visible: > > inoremap <expr> <CR> pumvisible() ? "\<C-y>\<CR>" : "\<CR>" OT: The backslashes should be omitted: :inoremap <expr> <CR> pumvisible() ? "<C-y><CR>" : "<CR>" because key codes are expanded when the mapping is defined. > But with this key mapping, abbreviations are not expanded by > <CR>. It's uncomfortable. Just my opinion. In particular, <CR> should always trigger an abbreviation that is already found in the buffer: <CR> (typed) expands an abbrev :imap somekey <CR>... expands an abbrev :ino somekey <CR>... should expand an abbrev, currently doesn't Of course, if the abbreviation is inserted with the :inoremap command, it should not be expanded: :iabbr myabbr myexpansion :ino somekey myabbr<CR> should not (and does not) expand the abbrev If this is not easy to implement (I don't know), it would be nice if at least i_Ctrl-], c_Ctrl-] could be improved. > I wrote a patch to add such pseudo key <AbbrExpand>. See the > attached file for the detail. With <AbbrExpand>, the above > mapping can be fixed as the following: > > inoremap <expr> <CR> pumvisible() ? "\<C-y>\<CR>" : "\<AbbrExpand>\<CR>" > > What do you think about this? Useful, or not? Probably very useful if <AbbrExpand> was the improved <C-]>. -- Andy --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_dev" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---
