Table of Contents
Vi/vim
= Vi/Vim - Text Editor =
Additional Configuration
Syntax Highlighting
By default - vim doesnt have syntax highlighting turned on. Vi (previous version to “VImproved”) does not have this syntax highlighting feature (as far as Im aware). ::apt-get install vim will install the later version and take the place of vi. Therefore to Turn on Syntax Highlighting: :syntax on //The above is for a once-off while inside vim.
vi /etc/vim/vimrc //Uncomment: syntax on
Helpful Commands
Search
To search for a word in vim, carry out the following: press Esc. (twice etc. to cancel out of editing mode) /wordtosearchfor (simply - put / and then the word) / (to search for the same word again - just type / )
.vimrc Using vim for PHP Coding
VIM has some very very useful tools to help you editing. So much so, you or me doesnt know the half of them. Here is my .vimrc for editing PHP files. The main source I used is: http://pookey.co.uk/wiki/php/vimrc with some corrections and tweaks. Note: Quotes are used to denote comments in .vimrc.
My .vimrc
set background=dark
“ Use incremental searching set incsearch
” Set standard setting for PEAR coding standards set tabstop=4 set shiftwidth=4
“ Auto expand tabs to spaces set expandtab
” Auto indent after a { set autoindent set smartindent
“ Linewidth to endless set textwidth=0
” Do not wrap lines automatically set nowrap
“ Show line numbers by default ” set number (not using this)
“ Repair wired terminal/vim settings set backspace=start,eol
“Map <CTRL>-B to run PHP parser check map <C-B> :w !php -l<CR>
” The completion dictionary is provided by Rasmus: ” http://lerdorf.com/funclist.txt set dictionary-=/home/sburke/.phpfunctionslist.txt dictionary+=/home/sburke/.phpfunctionslist.txt “ Use the dictionary completion. Use CTRL+N or CTRL+P while in INSERT mode to call completion. set complete-=k complete+=k
set list set listchars=tab:>-,trail:- “set listchars=tab:>-,trail:-,eol:$ “Puts a $ at the end of every line set ignorecase ” caseinsensitive searches set showmode ” always show command or insert mode set ruler ” show line and column information set showmatch “ show matching brackets set formatoptions=tcqor set whichwrap=b,s,<,>,, syntax on
set keywordprg=/home/sburke/.phphelp ” and .phphelp looks like: “####### ”#!/usr/bin/bash “links http://www.php.net/$1 ”####### “Hit SHIFT+k in command mode.
Links: <br> http://pookey.co.uk/wiki/php/vimrc <br> http://www.vim.org/scripts/script.php?script_id=1355 <br> http://wiki.cc/php/?title=Epc_phpm <br> http://vim.sourceforge.net/tips/tip.php?tip_id=598
Errors with VIM
If you get some of the following errors: E575: viminfo: Illegal starting char in line: 00100000 A phys_startup_32 E575: viminfo: Illegal starting char in line: c0100000 A _text E575: viminfo: Illegal starting char in line: c0100000 T startup_32 E575: viminfo: Illegal starting char in line: c01000a4 T startup_32_smp E575: viminfo: Illegal starting char in line: c0100124 t checkCPUtype E575: viminfo: Illegal starting char in line: c01001a5 t is486 E575: viminfo: Illegal starting char in line: c01001ac t is386 E575: viminfo: Illegal starting char in line: c010020e t check_x87 E575: viminfo: Illegal starting char in line: c0100236 t setup_idt E575: viminfo: Illegal starting char in line: c0100253 t rp_sidt E136: viminfo: Too many errors, skipping rest of file Press ENTER or type command to continue
The above means that your ~/.viminfo (in your home directory) is corrupted. This is only a history file, so it can be easily removed. rm ~/.viminfo That should be it :)
Reference: http://www.karakas-online.de/forum/viewtopic.php?t=656