Thursday, November 13, 2008

Vim - my config on CentOS

set vim as a default editor
echo "export EDITOR=/usr/bin/vim" >> /etc/profile
disable flow control in a terminal (unblock ctrl+s, ctrl+q for use in vim)
echo "stty -ixoff -ixon" >> ~/.bashrc

config:
echo '
set mouse=a
set number
set ts=2
set shiftwidth=2
set expandtab
set softtabstop=2
set smartindent
map <c-q> :mksession! ~/.vim/.session <cr>
map <c-s> :source ~/.vim/.session <cr>
nmap <F2> :update <cr>
imap <F2> <C-O>:update <cr>
' >> /etc/vimrc

Without the key mappings above, vim would be too painful for me to use for programming.
Ctrl+q ... save vim's state e.g. what files are opened, cursor position, ...
Ctrl+s ... restore saved state
F2 ... save current file - works in insert mode too

X11 clipboard
http://lug.wsu.edu/node/1239
yum install vim-X11
echo "alias vim='/usr/bin/vimx'" >> ~/.bashrc
. ~/.bashrc

rails support
http://www.vim.org/scripts/script.php?script_id=1567

Before running, check for latest version and replace 9499 below.
mkdir ~/.vim
cd ~/.vim
wget http://www.vim.org/scripts/download_script.php?src_id=9499
unzip rails.zip
rm rails.zip

enable rails docs
:helptags ~/.vim/doc
then run
:help rails

haml+sass syntax highlighting
http://www.vim.org/scripts/script.php?script_id=1773
http://www.vim.org/scripts/script.php?script_id=1979
Again, check for latest versions and modify 8461 and 7447 below.
mkdir ~/.vim/syntax
cd ~/.vim/syntax
wget http://www.vim.org/scripts/download_script.php?src_id=8461
wget http://www.vim.org/scripts/download_script.php?src_id=7447
echo '
au! BufRead,BufNewFile *.haml setfiletype haml
au! BufRead,BufNewFile *.sass setfiletype sass
' >> ~/.vim/filetype.vim

problem with haml.vim - carriage returns errors
http://railshacks.blogspot.com/2008/05/railsvim-breaks-in-hardy-heron.html
vim ~/.vim/syntax/haml.vim
and save with
:w ++ff=unix

Swap Escape and Caps Lock keys (to love vim more)
http://www.ibiblio.org/pub/Linux/docs/HOWTO/Keyboard-and-Console-HOWTO
echo '
remove Lock = Caps_Lock
keysym Escape = Caps_Lock
keysym Caps_Lock = Escape
add Lock = Caps_Lock
'> ~/.Xmodmap

File ~/.Xmodmap is processed by /etc/X11/xinit/xinitrc-common when X starts.
To take effect immediately, do
'xmodmap ~/.Xmodmap'

Same on Windoze
http://www.emacswiki.org/emacs/MovingTheCtrlKey#toc11
save the next 3 lines in a file, e.g. swapEscCL.reg and execute
REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,01,00,3a,00,3a,00,01,00,00,00,00,00

tips
:%s/^/ / ... indent all lines
:.,.+3s/^/ / ... indent 4 lines from cusor down
<c-v>2><esc> ... indent 2x on a selected range

references
vim as development environment

to do
fix problem with javascript highlighting
now have to do
:set
syntax=javascript
perhaps filetype is not correctly set for js

2 comments:

Anonymous said...

Today Matchpoint | Casino Review | Up to 100% Bonus
In our 샌즈카지노 Casino 메리트카지노 Review, we will review matchpoint's casino and review the bonuses and payment methods. matchpoint It's free casino games, no deposits

Anonymous said...

Oshi Casino: A Member of The Casino Rewards Club
oshi casino. air jordan 18 retro yellow shipping Oshi 토토캔 casino. Member of the casino rewards club at 777 꽁머니 토토 Casino air jordan 18 retro yellow suede great site St. John, 동행복권 먹튀 LA 70113 USA.