Vim run autocmd on all filetypes EXCEPT

*.rb isn’t a filetype. It’s a file pattern. ruby is the filetype and could even be set on files that don’t have a .rb extension. So, what you most likely want is a function that your autocmd calls to both check for filetypes which shouldn’t be acted on and strips the whitespace. fun! StripTrailingWhitespace() ” … Read more

How to map Ctrl+A and Ctrl+Shift+A differently?

Gvim doesn’t do it because vim cannot do it (under normal circumstances). Sorry, but that’s just how it is. However… Some terminals (e.g., xterm and iterm2) can be configured to send an arbitrary escape sequence for any combination of keys. For example, add the following to .Xresources for xterm to send <Esc>[65;5u for CtrlShiftA. You … Read more

How to copy selected lines to clipboard in vim

SHIFTV puts you in select lines mode. Then “+y yanks the currently selected lines to the + register which is the clipboard. There are quite a few different registers, for different purposes. See the section on selection and drop registers for details on the differences between * and + registers on Windows and Linux. Note … Read more

Vim – how to run a command immediately when starting vim?

The best place to keep your configuration stuff is in your .vimrc file. However, it’s sourced too early, check :h startup: At startup, Vim checks environment variables and files and sets values accordingly. Vim proceeds in this order: 1. Set the ‘shell’ and ‘term’ option *SHELL* *COMSPEC* *TERM* 2. Process the arguments 3. Execute Ex … Read more