I love using GEdit to write text documents like blog posts marked up in Markdown. I’ve been using it extensively to write technical documentation for a while now. It’s a lovely text file editor.
Programming with GEdit is a bit more subject to critique. Sure, source code is text files, but as programmers we expect a fair bit of our editor. I’ve been writing my C code in vi
for like 25 years. When I returned to Java after a few years in dot-com land I (with great scepticism) began using Eclipse. IDEs are for wimps, after all. Boy was I wrong about that. Once I got the hang of its demented way of doing things, I was blown away at the acceleration that code completion, hierarchy navigation, and most of all context appropriate popups of JavaDoc. Hard to leave that behind.
Lately, however, I’ve been doing a lot of work with Haskell and JavaScript, and that ain’t happening in Eclipse. Since I use GEdit for so much else, I thought I’d give it a whirl for programming in other-than-Java. Didn’t work out so well. I mean, it’s almost there; I tried a bunch of plugins but it seems a bit of a crap shoot. To make development easier I’d certainly need e.g. ctags, but there was nothing packaged.
You’re probably asking why I’m not content to just use Vim from a terminal; after all, been doing so for years. I’ve begun to have a bit of a backlash against running applications in terminal windows; command lines are for doing Linux things, but once you run an editor or email client or whatever in a terminal then suddenly your productivity on the Desktop goes to hell; the whole premise of Alt+Tab
(we won’t even talk about the bizarre GNOME Shell Alt+
` business) is switching between applications but having both $
and programs in the same type of window blows that up.
Vim, however, has long had a GUI version called gVim, and when running it shows up as an independent application. So, for the hell of it, I gave it a try.
Cut and Paste
Immediately I went bananas becuase copy and paste didn’t work like they should. Yes this is vi; yank-yank, baby. But as gVim it’s also a GUI, and we’ve all pretty much learnt that if you’ve got a white canvas in front of you, Ctrl+C
and Ctrl+V
are going to work. So much so that I have gnome-terminal rejigged to to make Ctrl+Shift+C
result in SIGINT
leaving Ctrl+C
for copy. Consistency in user interaction is everything.
There’s an entire page on the Vim Tips Wiki devoted to using y
, d
, and P
to yank or delete then put. No kidding. But just as I was about to give up I found, buried at the bottom, advice to add:
source $VIMRUNTIME/mswin.vim
to your .vimrc
. The script affects some behaviour changes which among other things makes selection, cut, copy, and paste work like a normal GtkTextView widget. Hooray!
As for the rest of the GUI, I’ve gone to a lot of trouble to tame it. You need to make quite a number of changes to gVim’s default GUI settings; it’s all a bit cumbersome and the gVim menus (which at first seem like such a great idea!) don’t actually give you much help. Figuring these customizations out took a lot of wading through the wiki and worse the voluminous internal help documentation to figure any of this out; it’s pretty arcane.
Cursor
In particular, I want an unblinking vertical bar as a cursor (to match the desktop wide setting properly picked up by every other GNOME app, here I had to manually force it):
set guicursor=a:ver1,a:blinkon0
See the documentation for '
guicursor
'
for other possibilities.
Mouse pointer
Also for consistency, I needed to get standard behaviour for the mouse pointer (in particular, it’s supposed to be an I-beam when over text; the ability to change pointer depending on which mode you’re on is interesting, but it is jarring when compared to, well, everything else on the Desktop):
set mouseshape=n:beam,ve:beam,sd:updown
The documentation for '
mouseshape
'
describes enough permutations to keep even the most discerning customization freak happy.
Window dressing
The remaining settings are certainly personal, but you’ll want to pick a default window size that makes decent use of your screen real estate:
if has("gui_running")
set lines=45 columns=95
endif
You need to guard with that if block because otherwise running vim
from your command line will resize your terminal (!) and that’s annoying.
You can set the editor font from the menu, but to make it stick across program invocations you need it in .vimrc
as shown here; finally, the '
guioptions
'
at the end disables tearoff menus (t
) and turns off the toolbar (T
):
set guifont=DejaVu\ Sans\ Mono\ 11
set guioptions-=tT
Syntax colouring
I normally use Vim in a terminal with a black background, but for some reason I don’t much like the colour set chosen. Forcing the change to 'light'
makes for a nicely different set, but since I run gVim with a white background to be consistent with other GUI programs, I had to do a bit of tweaking to the colours used for syntax highlighting:
set background=light
highlight Constant ctermfg=Blue guifg=DarkBlue
highlight String ctermfg=Blue cterm=bold guifg=DarkBlue gui=bold
highlight Comment ctermfg=Grey guifg=DarkGrey
Hopefully that does it. As I said, the new Vim wiki is full of an insane amount of information, but since Vim is so powerful it can, ironically, be hard to find what you need to fine tune things just the way you want them. So if you’re a power Vim or gVim user, why don’t you blog about your .vimrc
settings?
Still not sure if using gVim is going to be a good idea; the fact that despite all this hackery the editor canvas is still not a GNOME app with behaviour matching the standards of the entire rest of the Desktop is going to make me crazy. Hopefully I can keep things straight in my head; frankly I’d rather be using GEdit but it is nice to have consistency between using Vim to do sysadmin work and using gVim to write code.
AfC