I work on several Linux servers through SSH all from a single Linux workstation and I use GVim as my preferred editor. I tend to have several windows open at the same time and sometimes I’m editing the same file name on different servers. So, I decided to use the background color as a quick visual cue as to which server I’m working on.
I’m vaguely familiar with Vim’s colorscheme option, but I haven’t looked at it since I selected my favorite scheme years ago. Now, I just keep copying the same .vimrc and .gvimrc files to each workstation. But for this task, I had to return to the online documentation briefly to see how the color schemes work.
When Vim receives a colors[cheme] command, it searches the runtimepath directories for colors/<colorscheme>.vim.
Here are the steps I took:
- Created a colors subdirectory in one of the runtimepath directories (/home/ghodmode/.vim).
- Copied a colorscheme file (darkblue.vim) from $VIMRUNTIME/colors (/usr/share/vim/vim72/colors) to the new colors directory under a different name (ghodmode.vim).
- Changed the colors_name value.
- Changed the guibg value on the hi Normal line to the HTML background color I wanted.
- Added colorscheme ghodmode to the top of my .gvimrc file.
I played with the idea of using a hostname as the name of the scheme file, but I couldn’t get it to work. If I’m in Vim and I use the command colorscheme `hostname`, it works fine, but the back-ticks don’t work from the .gvimrc. Also, I don’t know how to apply this concept in Windows. I’ll bet there’s a way to do this with Vim’s scripting language, though.
–
– Ghodmode