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

Linux vi arrow keys broken in insert mode

I presume you’re using vim as this is tagged as Linux. Try: :set nocompatible (You may want to configure your .vimrc with this by adding this command to it. Create a new .vimrc file if not already present in your home directory, run echo $HOME to check home directory path.)

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

Highlight changed lines and changed bytes in each changed line

The diff-highlight Perl contrib script produces output so similar to that of the Trac screenshots that it is likely that Trac is using it: Install with: wget https://raw.githubusercontent.com/git/git/fd99e2bda0ca6a361ef03c04d6d7fdc7a9c40b78/contrib/diff-highlight/diff-highlight && chmod +x diff-highlight Move the file diff-highlight to the ~/bin/ directory (or wherever your $PATH is), and then add the following to your ~/.gitconfig: [pager] diff … Read more

Setting the Vim background colors

As vim’s own help on set background says, “Setting this option does not change the background color, it tells Vim what the background color looks like. For changing the background color, see |:hi-normal|.” For example :highlight Normal ctermfg=grey ctermbg=darkblue will write in white on blue on your color terminal.