I am trying to implement autosave in vim.
I managed to put together these lines using this article - Understand Vim Mappings and Create Your Own Shortcuts! and added them to .vimrc
" auto save on esc noremap <silent> <esc> <esc>:w<CR> inoremap <silent> <esc> <esc>:w<CR>
<esc>, vim returns to normal mode and executes the write command with
<enter>. Nothing outputs to command area with the silent argument.
The first line add non recursive mapping in normal, visual and select mode. The second line does the same but in insert mode.
I'm assuming normal, visual and insert are the only modes that allow text editing.
I have two problems:
- The silent option isn't working.
- Every time i open a file in vim, the first character of the file is replaced with
g. And the command area contains the following text
When I comment out the two lines in .vimrc, the problem is resolved.