History of SelectedVimTips
{maketoc}
! useful .(g)vimrc mappings
!! vim to the rescue!
what do you do when you have a php function in front of you and you don't know what it does or you can't remember in what order the parameters are passed in?
i'm not sure what you do, but i move my cursor onto that function and hit <Ctrl-P>. that's it!
just recently i stumbled accross this useful [http://www.vim.org/tips/tip.php?tip_id=922|vim tip]:
it allows you to position your cursor on any php function and using your mapping it will open the appropriate page on www.php.net
i use this in my .vimrc
{code()}
" open window in browser with php function under cursor
if has("gui_running")
nmap <c-p> :!lynx -accept_all_cookies http://us2.php.net/^R^W\#function.^R^W<CR>
elseif
nmap <c-p> :!opera -newpage http://us2.php.net/^R^W\#function.^R^W<CR>
endif
{code}
obviously you can replace opera with your favourite browser and replace the mapping with your preferred mapping. unfortunately lynx doesn't work in gvim and thus you need to open the page in an external browser.
^__Note:__ don't forget to use <Ctrl-V><Ctrl-R> and <Ctrl-V><Ctrl-W> to get ~np~^R and ^W~/np~^
! some useful .vimrc settings
!! auto source .vimrc on save
{code()}
if has("autocmd")
" source the .vimrc file on save to apply all changes immediately
autocmd! bufwritepost .vimrc source ~/.vimrc
endif
{code}
!! setting up vim for TikiPro
{code()}
if has("autocmd")
autocmd bufnewfile,bufenter * set noet ts=4 sw=4
endif
{code}
!! using Ctrl-A and Ctrl-X
you can increase number using <Ctrl-A> and decrease them using <Ctrl-X>. if you do this with padding zeros, it might cause problems as 0777 is an octal value and increasing this will give you some strange results. to avoid this, add the following to your .vimrc:
{code()}
set nrformats-=octal
{code}
! generic vim tips and tricks
!! :grep
grep can be used from within vim. it's basically as if you're using it in a console, but it has some great bonuses when using it from within vim.
say you are in the root directory of /tikipro/, try tiping the following:
{code()}
:grep -rni --include="*.tpl" 'html_checkboxes' *
{code}
this will generate some lines of where grep finds the occurances of 'html_checkboxes'. once done, hit enter and it will open a page with the first occurance.
once you are done editing this code, you can type:
{code()}
:copen
{code}
this will open a new window in the bottom right corner with all the results grep found earlier. all you do now is move the cursor onto the file of interest and hit <enter> or double click on the file of interest (if you have mouse support enabled).
if you should do a new search on top of the initial search, you can follow the same procedure and return back to the 'html_checkboxes' results by typing:
{code()}
:colder
{code}
returning back to the more recent results, you just need to type:
{code()}
:cnewer
{code}
!!! background reading
{code()}
:he :grep
:he :copen
{code}
! useful .(g)vimrc mappings
!! vim to the rescue!
what do you do when you have a php function in front of you and you don't know what it does or you can't remember in what order the parameters are passed in?
i'm not sure what you do, but i move my cursor onto that function and hit <Ctrl-P>. that's it!
just recently i stumbled accross this useful [http://www.vim.org/tips/tip.php?tip_id=922|vim tip]:
it allows you to position your cursor on any php function and using your mapping it will open the appropriate page on www.php.net
i use this in my .vimrc
{code()}
" open window in browser with php function under cursor
if has("gui_running")
nmap <c-p> :!lynx -accept_all_cookies http://us2.php.net/^R^W\#function.^R^W<CR>
elseif
nmap <c-p> :!opera -newpage http://us2.php.net/^R^W\#function.^R^W<CR>
endif
{code}
obviously you can replace opera with your favourite browser and replace the mapping with your preferred mapping. unfortunately lynx doesn't work in gvim and thus you need to open the page in an external browser.
^__Note:__ don't forget to use <Ctrl-V><Ctrl-R> and <Ctrl-V><Ctrl-W> to get ~np~^R and ^W~/np~^
! some useful .vimrc settings
!! auto source .vimrc on save
{code()}
if has("autocmd")
" source the .vimrc file on save to apply all changes immediately
autocmd! bufwritepost .vimrc source ~/.vimrc
endif
{code}
!! setting up vim for TikiPro
{code()}
if has("autocmd")
autocmd bufnewfile,bufenter * set noet ts=4 sw=4
endif
{code}
!! using Ctrl-A and Ctrl-X
you can increase number using <Ctrl-A> and decrease them using <Ctrl-X>. if you do this with padding zeros, it might cause problems as 0777 is an octal value and increasing this will give you some strange results. to avoid this, add the following to your .vimrc:
{code()}
set nrformats-=octal
{code}
! generic vim tips and tricks
!! :grep
grep can be used from within vim. it's basically as if you're using it in a console, but it has some great bonuses when using it from within vim.
say you are in the root directory of /tikipro/, try tiping the following:
{code()}
:grep -rni --include="*.tpl" 'html_checkboxes' *
{code}
this will generate some lines of where grep finds the occurances of 'html_checkboxes'. once done, hit enter and it will open a page with the first occurance.
once you are done editing this code, you can type:
{code()}
:copen
{code}
this will open a new window in the bottom right corner with all the results grep found earlier. all you do now is move the cursor onto the file of interest and hit <enter> or double click on the file of interest (if you have mouse support enabled).
if you should do a new search on top of the initial search, you can follow the same procedure and return back to the 'html_checkboxes' results by typing:
{code()}
:colder
{code}
returning back to the more recent results, you just need to type:
{code()}
:cnewer
{code}
!!! background reading
{code()}
:he :grep
:he :copen
{code}