Cygwin vim ships with vim's default configuration, which leaves vim in vi compatibility mode where it tries to emulate the original vi as closely as possible. Among other limitations, arrow keys do not work in that mode, and backspace just moves the cursor left rather than erasing a character.
Creating an empty ~/.vimrc
is sufficient to disable vi compatibility mode:
touch ~/.vimrc
Having said that, i to enter insert mode should work anyway. You'll need to provide more details on where and how you're running vim. Also, are you actually running the vim that comes with Cygwin, or the native Windows version of vim?
Update
You can add below sets in ~/.vimrc to make is similar to default vim
set nocompatible
set backspace=indent,eol,start
set backup
set history=50
set ruler
set background=dark
set showcmd
set incsearch
syntax on
set hlsearch
If vim does not pick up your vimrc file, it may be looking for a .virc
file instead. In this case, rename the file and the changes will be applied.
I am responding to this question four years later because the answer provided is a partial solution that does not completely address the original question.
I have the exact same desire as olibre, and wanted to come up with a complete solution. I come at it from a different perspective -- I'm used to Emacs line editing in bash -- but the issue is the same. I want to carry that over into Vim insert mode (only).
The following addresses all of the keybinding requests in the original question posed by olibre, plus few extras:
" Mimic Emacs Line Editing in Insert Mode Only
inoremap <C-A> <Home>
inoremap <C-B> <Left>
inoremap <C-E> <End>
inoremap <C-F> <Right>
" â is <Alt-B>
inoremap â <C-Left>
" æ is <Alt-F>
inoremap æ <C-Right>
inoremap <C-K> <Esc>lDa
inoremap <C-U> <Esc>d0xi
inoremap <C-Y> <Esc>Pa
inoremap <C-X><C-S> <Esc>:w<CR>a
The only bindings I cannot seem to get to work at this point are <Alt-B>
and <Alt-F>
, which would skip entire words. Whenever I bind <Esc>
, <Alt>
, or <Meta>
combinations, gVim (v7.4 on Windows) outputs accented characters. Please feel free to edit this answer if you have a solution to this issue. I have gotten Alt combinations to work based on another post's suggestion to just use the special characters. I have inserted them above.
Edit
-- (edit is not by original answer poster) --
I used the following under Neovim and Windows 10. You might need to change the "A" into "M" on other OSs as "alt" might be "meta" elsewhere. I haven't played with it enough.
inoremap <A-x> <Esc>:
inoremap <A-f> <Esc>lwi
inoremap <A-b> <Esc>bi
inoremap <A-S-f> <Esc>lWi
inoremap <A-S-b> <Esc>Bi
Best Answer
The last one illustrates the use of Ctrl-o in Insert mode, which lets you interrupt insert mode to use exactly one normal mode command before returning.