This document should be treated only as a general introduction not as complete document about vim. Where it is more appropriate I give just short explanation and provide links to external resources that I found useful and that provide more information. I recommend to check provided links for more detailed information.
vim brief introduction
The vim text editor is very powerful tool that can be used in text as well as graphical environment. It is based on vi text editor. If you are already Linux user you are probably using this text editor most likely to amend configuration files.
For more information about vim please check below link - there are links I use:
- http://www.vim.org - this is main website where you can find more information about Vim project.
- http://vimdoc.sourceforge.net - vim online user documentation (manuals in various formats, you can as well download book in PDF format for free).
- http://www.vim.org/community.php - in case you need help the best place is to look for help within online community.
- http://vim.wikia.com/wiki/Vim_Tips_Wiki - WIKIBook, visit it and search for tips and tricks.
- http://en.wikibooks.org/wiki/Learning_the_vi_Editor/Vim - vim online tutorial.
- http://vim.runpaint.org/ - vim recipes.
Above links should allow you to find/learn about general use of vim - If you new or want to learn new tricks. In the remaining part of this document I am going to write more about specific steps to configure vim to support Drupal development.
Like with all the new tools there is a learning curve involved but to make it easier you may start using graphical version of vim called Gvim - most of the options you can find from menu (keyboard shortcuts provided for your convenience).
Steps to install vim on Ubuntu:
In case you do not have vim installed below are commands that allow you to install it on Ubuntu/Debian:
sudo apt-get update # installing console version of vim sudo apt-get install vim # installing GUI based vim sudo apt-get install vim-gnome
Setting up vim for Drupal developers:
When I was reading how to set up vim for Drupal developers I found below pages very useful:
- http://drupal.org/project/vimrc - use this link to learn how to install plugins to support Drupal development via drush tool.
- http://drupal.org/node/29325 - simple configuration steps for vim.
You should refer to above links for detailed information. I will show steps I did to set up vim on my Ubuntu machine:
Before you go to next steps make sure that vim and drush is available on your system - if you do not have them please install them now. In most cases you would be able to install it from Ubuntu/Debian repository.
- Instruction to install vim configuration files for Drupal developers
drush @none dl vimrc drush -v vimrc-install
After running above command you can find:
- ~/.drush/vimrc - drush downloads to this directory vim configuration files for Drupal development, for more information please read README.txt
- ~/.vim/ - in this folder we have some additional plugins that are installed by default (requires drush version 5.5+), we can add more if we need here in the future. These plugins here are general one not tailored to Drupal development.
In during this step drush adds instruction to user's vim configuration file ~/.vimrc - in order to include script/plugins from above locations (~/.drush/vimrc/bundle and ~/.vim/bundle). At this moment vim is configured to enhance Drupal/web development on our machine.
- Edit .vimrc to add some more settings
Above is what I added to my .vimrc file:
" I use vim configuration file that comes with vimrc project source ~/.drush/vimrc/examples/vimrc_timplunkett.vim " Below lines are for general vim settings set expandtab set tabstop=2 set shiftwidth=2 set autoindent set smartindent syntax on " changed default colorschema to elflord " additional colorschame check /usr/share/vim/vim73/colors " or search Internet, download and enable colorscheme elflord
- To test that vim now provides support for Drupal developers, browse to your Drupal project (vim would detect version of Drupal, as well type of file you edit and uses correct setting) and edit file and try things that are on this vimrc project page as well as this documentation page.
In nutshall we: installed vim, amended user's vim configuration file, downloaded additional plugins that extend default functionality of vim - and we did this typing just two command in the terminal.
This is just a starting point - more you develop more additional plugins and scripts you may want to install to be able to develop faster and spend more time on writing more efficient and elegant code.
In my next article I am going to provide some more explanation of components that we have installedhow as well as show examples how to use installed vim plugins.