简体   繁体   中英

Mapping 'Ctrl + O' in vim doesn't work

I freshly installed Ubuntu 16.04 and then I installed vim. Soon I realized that Ctrl + O which I regularly use in vim to jump to the last place, does not work! After some search, I got the following commands:

:nnoremap <M-Left> <C-O>

and

:nnoremap <X1Mouse> <C-O>

I tried putting both these in my .vimrc but they don't give me the desired effect. I am really annoyed by this since this is one of the most used things that I use. What am I missing?

Edit : I reinstalled vim from scratch, also deleted the ~/.vimrc file. After deleting the file, I checked for /usr/share/vim/vimrc ; it was there. Then I installed vim and tested for Ctrl+o ; it works till I close the file. However, after I open it back, it forgets all the history.

Well, the actual answer as mentioned in the comments is your vim config files didn't have proper permissions on them. In addition to that, the key mappings you used in your question are invalid according to the docs:

:help X1Mouse

The X1 and X2 buttons refer to the extra buttons found on mice.
The 'Microsoft Explorer' mouse has these buttons available to the right thumb.
Currently X1 and X2 only work on Win32 environments.

And

:h M-Left
Alt-Left        Move cursor to the beginning of the previous word

M = alt.

Put this in your vimrc. Enable the mouse first:

set mouse=a
map <LeftMouse> <c-o>

Although Vim uses inefficient gluing of movements together if you want to get to a far away arbitrary place on the screen, which the mouse solves well and much faster than Vim :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM