8

When I edit .sql file in VIM, I can't use left/right cursor keys while in insert mode. In normal mode they work just fine. In another file types - they work fine as well. in ~/.vim/ftplugin/sql.vim there is bunch of "iab"s, but not much more.

I found out that when running vim with standard vimrc, not-customized, the problem is not existing.

What could be wrong? Is there any option that could have been set, that disables some (up and down work) cursor keys in insert mode ?!

2 Answers 2

6

It may be that somehow the keys have become mapped to a command. Type :mapCtrlV to see if the right arrow has been mapped, and the same for left arrow after.

4
  • 1
    Both show "No mapping found". But, after doing :imap, I saw: i <Left> @<C-R>=sqlcomplete#DrillOutOfColumns()<CR> and i <Right> @<C-R>=sqlcomplete#DrillIntoTable()<CR> I was able to trace it back to filetype plugin indent on in my .vimrc, so i disabled it, but I have no idea what this sqlcomplete#... stuff is, and why it broke my left and right cursors.
    – user7385
    May 10, 2010 at 16:49
  • 1
    Sounds like functionality provided by this: vim.org/scripts/script.php?script_id=1572 May 10, 2010 at 16:57
  • @depesz: enabling 'filetype plugin' basically means special functionality may be loaded in buffers for files that have a filename extension that's linked to an available "plugin". The special plugin kay mappings would be loaded only when editing a file of that type, i.e., with that extension in the filename. Disabling all plugins (i.e., what you did) would fix the "problem", or you could also likely avoid the problem by renaming the problematic files to have a different extension. (Or you could uninstall just the SQLComplete plugin, assuming that's the one that's causing the problem.) May 10, 2010 at 17:09
  • @Herbert: I have no idea about this "SQLComplete" plugin - never installed it, never wanted. Probably came with vim installation in ubuntu.
    – user7385
    May 10, 2010 at 18:52
15

Add the following to your ~/.vimrc or ~/.vim/ftplugin/sql.vim file:

let g:omni_sql_no_default_maps = 1
1
  • This solved it for me. The accepted answer correctly answers the question, but this actually fixes the problem. :)
    – oalders
    Jul 18, 2013 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.