Jul 8, 2011

Windows compatible keyboard layout for nano editor

This post is not about C#, but sometimes fortune bring You to some places, where You never been before. For example, may be You need to install Your .NET Web Service on Unix platform. Have You ever have nightmare to edit files in vim? But not all so bad.

Nano editor is one of convenient text editors in unix. If You ever have trouble with vim (I do) You could find nano editor very friendly. But unix people make difficult anything that can be very easy. Keyboard layout is unbelievable inconvenient... what authors smoking? Fortunately it can be easy fixed by .nanorc file. Symply make new file .nanorc in home directory with content followed below. It will make keyboard bindings almost same as on Windows.

After restart nano editor will use standard shortcuts - Ctrl-S for save, Ctrl-O for open files, Ctrl-C for copy, Ctrl-V for paste, etc. Although there is some problem with undo/redo. Seems undo shortcut is hardcoded to Alt-U and Alt-Y for redo.

~/.nanorc

set undo
set autoindent
set mouse

bind ^S writeout main
bind ^O insert main
bind ^G gotoline main
bind ^X cut main
bind ^V uncut main
bind ^C copytext main
bind ^H replace main
bind ^Q exit main
bind ^Z undo main
bind ^F whereis main
bind F3 searchagain main
bind F1 help main

Updated layout:

Ctrl-Q leaved for exit for compatibility
Cut line replaced by Ctrl-Y, which is common for cut line

set undo
set autoindent
set mouse

bind ^S writeout main
bind ^O insert main
bind ^G gotoline main
bind ^Y cut main
bind ^V uncut main
bind ^C copytext main
bind ^H replace main
bind ^Z undo main
bind ^F whereis main
bind F3 searchagain main
bind F1 help main