<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>teranex weblog - programming</title><link href="https://budts.be/" rel="alternate"></link><link href="https://budts.be/feeds/programming.atom.xml" rel="self"></link><id>https://budts.be/</id><updated>2010-12-18T12:31:00+01:00</updated><entry><title>VIM: working with "light-projects"</title><link href="https://budts.be/weblog/2010/09/vim-working-with-light-projects" rel="alternate"></link><published>2010-09-29T23:32:00+02:00</published><updated>2010-12-18T12:31:00+01:00</updated><author><name>Jeroen Budts</name></author><id>tag:budts.be,2010-09-29:/weblog/2010/09/vim-working-with-light-projects</id><summary type="html">&lt;p&gt;While VIM certainly isn't an IDE, there are a lot of plugins in existence to make it more IDE-like. Although I have been working a lot inside IDE's the past few years, I don't really need all those fancy IDE features (and the bloat that comes with it). That's one of the many things I like so much about Vim, I can just add the features I need to the editor. So while there are certainly at least a few plugins to work with projects inside Vim, I came up with my own system for working with "projects" (call them "light-projects" if you wish). One small note: For the moment this method suits my needs, but since I'm only using Vim for about two months as my main editor, this might change obviously.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Basically, my solutions is based on an autocommand for every 'project' and the &lt;a href="http://www.vim.org/scripts/script.php?script_id=3025"&gt;command-t plugin&lt;/a&gt;. Oh, and sessions as well. The autocommand detects when a file is read (or created) inside the project-directory. In this case, it …&lt;/p&gt;</summary><content type="html">&lt;p&gt;While VIM certainly isn't an IDE, there are a lot of plugins in existence to make it more IDE-like. Although I have been working a lot inside IDE's the past few years, I don't really need all those fancy IDE features (and the bloat that comes with it). That's one of the many things I like so much about Vim, I can just add the features I need to the editor. So while there are certainly at least a few plugins to work with projects inside Vim, I came up with my own system for working with "projects" (call them "light-projects" if you wish). One small note: For the moment this method suits my needs, but since I'm only using Vim for about two months as my main editor, this might change obviously.&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Basically, my solutions is based on an autocommand for every 'project' and the &lt;a href="http://www.vim.org/scripts/script.php?script_id=3025"&gt;command-t plugin&lt;/a&gt;. Oh, and sessions as well. The autocommand detects when a file is read (or created) inside the project-directory. In this case, it will source the correct 'vimrc-project-file' and setup everything specific for the project. So as an example, suppose we have a project in &lt;code&gt;~/Projects/foobar/&lt;/code&gt;. In my &lt;code&gt;.vimrc&lt;/code&gt; I add the following line (to be more correct, for most of the projects I would add the line in my &lt;a href="http://budts.be/weblog/2010/09/using-your-bash-and-vim-config-on-multiple-computers/"&gt;host-specific vimrc-file&lt;/a&gt;, as I mostly use one specific computer to work on a specific project):&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;autocmd &lt;span class="nb"&gt;BufRead&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="nb"&gt;BufNewFile&lt;/span&gt; &lt;span class="p"&gt;~&lt;/span&gt;&lt;span class="sr"&gt;/Projects/&lt;/span&gt;foobar&lt;span class="sr"&gt;/* source ~/&lt;/span&gt;.&lt;span class="k"&gt;vim&lt;/span&gt;&lt;span class="sr"&gt;/projects/&lt;/span&gt;foobar.&lt;span class="k"&gt;vim&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;This autocommand simply sources the foobar.vim file everytime a file in the foobar directory is read, or created. Since the foobar.vim project-file is just a regular vim-script file, you can do anything you want in it. I mostly use it to set some editor properties and add some additional mappings, such as:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c"&gt;&amp;quot; I use autochdir by default, but for this project I prefer&lt;/span&gt;
&lt;span class="c"&gt;&amp;quot; to always be in the project-root. So we first disable the&lt;/span&gt;
&lt;span class="c"&gt;&amp;quot; autochdir option&lt;/span&gt;
&lt;span class="k"&gt;setlocal&lt;/span&gt; &lt;span class="nb"&gt;noautochdir&lt;/span&gt; 

&lt;span class="c"&gt;&amp;quot; and then we cd to the project-root&lt;/span&gt;
&lt;span class="k"&gt;cd&lt;/span&gt; &lt;span class="p"&gt;~&lt;/span&gt;&lt;span class="sr"&gt;/Projects/&lt;/span&gt;foobar/

&lt;span class="c"&gt;&amp;quot; in this project i like to use ant, so set it up as the make program inside vim&lt;/span&gt;
&lt;span class="k"&gt;setlocal&lt;/span&gt; &lt;span class="nb"&gt;makeprg&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;ant\ &lt;span class="p"&gt;-&lt;/span&gt;find\ build.xml
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I have some other options in my project-vimrc file which are more specific to exploring and navigating code, but I will explain these in a later post I plan to write.&lt;/p&gt;

&lt;p&gt;So that's it for automatically configuring vim with settings specific to your project when editing one of the files of that project. One other important aspect of working with projects is to be able to easily open any file of your project. Most IDE's have fancy file-explorers, and a lot of vim-users seem to love the &lt;a href="http://www.vim.org/scripts/script.php?script_id=1658"&gt;NERDtree plugin&lt;/a&gt;. But a few years ago, when I found the &lt;a href="http://plugins.jedit.org/plugins/?OpenIt"&gt;OpenIt plugin&lt;/a&gt; for jEdit, I discovered that I can type faster than search my way through a tree-structure of directories and files. &lt;a href="http://www.jetbrains.com/resharper/"&gt;Resharper&lt;/a&gt; adds a similar feature to VS.NET (did I already mention that Visual Studio is just crap without Resharper?). Just press a shortcut, start typing what you need, and let the program do the searching.&lt;/p&gt;

&lt;p&gt;For vim I found the &lt;a href="https://wincent.com/products/command-t"&gt;command-t plugin&lt;/a&gt;. After installing the plugin you can launch command-t with &lt;code&gt;&amp;lt;leader&amp;gt;t&lt;/code&gt; (unless you have changed your leader key it will be a backslash, so the correct mapping will be \t). Command-T will index your current directory and it's children. The fact that it indexes the current working directory is one of the reasons why I `cd` to the root of a project in my project-vimrc, so while working on a project Command-T will always index my entire project. The first time you launch it, command-t might take a few seconds before the indexing finishes (depending on the amount of files in the directory-tree), but the results are cached, so next time you launch Command-T it shows up almost instantly. Command-T will now show you a list of &lt;i&gt;all&lt;/i&gt; the files in your project. Now you can just start typing parts of the filename (or even of the path to the file) and Command-T will filter out the matching files. If the correct file is selected, simply press enter and Command-T will open the file. I really find this a lot easier than hunting down the file myself.&lt;/p&gt;

&lt;p&gt;One last feature of Vim I use for projects are sessions. If your Vim is compiled with session-support (it probably is), you can let Vim write a file which contains a list of all the buffers you have opened (and mappings etc which you have defined while editing). When you want to continue working on your project, you can simply instruct Vim to open the session from the session-file and Vim will restore all the opened buffers, mappings etc.&lt;/p&gt;

&lt;p&gt;While this is already useful, I think it still requires to many manual actions. No problem, plugins to the rescue! The &lt;a href="http://www.vim.org/scripts/script.php?script_id=2010"&gt;SessionMan plugin&lt;/a&gt; makes all of this a lot easier. The first time you start your project, simply save your session with &lt;code&gt;:SessionSave&lt;/code&gt;. SessionMan will notice that you currently don't have a session and ask for a name, so you can enter 'foobar' (if that is the very original name of your project). When you start vim again to continue working on your project you can now simply use the command &lt;code&gt;:SessionOpen foobar&lt;/code&gt; to open your foobar session. Also SessionMan will automatically save your session when quitting vim. Another useful command is &lt;code&gt;:SessionList&lt;/code&gt; (which I have mapped to &lt;code&gt;,s&lt;/code&gt;). This shows a list of all your sessions and lets your select the session which you want to open.&lt;/p&gt;

&lt;p&gt;So in short, when I want to continue working on a project:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;I launch gvim&lt;/li&gt;
  &lt;li&gt;I type &lt;code&gt;,s&lt;/code&gt; to open the sessionlist&lt;/li&gt;
  &lt;li&gt;I select the correct session&lt;/li&gt;
  &lt;li&gt;Vim restores all my opened buffers and windows&lt;/li&gt;
  &lt;li&gt;Thanks to the autocommand for the project, vim is correctly setup for the project&lt;/li&gt;
  &lt;li&gt;I can quickly open files with &lt;code&gt;\t&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;</content><category term="inuits-planet"></category><category term="programming"></category><category term="vim"></category><category term="work"></category></entry><entry><title>Learning Vim</title><link href="https://budts.be/weblog/2010/09/learning-vim" rel="alternate"></link><published>2010-09-11T18:05:00+02:00</published><updated>2010-12-18T12:31:00+01:00</updated><author><name>Jeroen Budts</name></author><id>tag:budts.be,2010-09-11:/weblog/2010/09/learning-vim</id><summary type="html">&lt;p&gt;When I started working on my first PHP project at &lt;a href="http://inuits.be"&gt;Inuits&lt;/a&gt; I had to decide which editor or IDE to use. Obviously while I was still working in the .NET-world I used Visual Studio, just as almost everybody else. However I also used jEdit at home for PHP, Ruby etc. I always felt that learning a general purpose editor, and learning it very well, is more interesting than learning an IDE for one specific platform (VS.NET in this case).&lt;/p&gt;

&lt;p&gt;&lt;a href="http://twitter.com/stijnbe"&gt;One of my new colleagues&lt;/a&gt; recommended me to use NetBeans for PHP development, so I had a look at it. While I'm sure it has a lot to offer, it just didn't feel like the tool I wanted to use. Obviously I had also installed jEdit. While I have always loved jEdit, somehow I wasn't convinced anymore. I also had a look at gEdit, which certainly has potential if you install some extra plugins and configure it, but compared to other editors and IDE's it seems to be rather limited …&lt;/p&gt;</summary><content type="html">&lt;p&gt;When I started working on my first PHP project at &lt;a href="http://inuits.be"&gt;Inuits&lt;/a&gt; I had to decide which editor or IDE to use. Obviously while I was still working in the .NET-world I used Visual Studio, just as almost everybody else. However I also used jEdit at home for PHP, Ruby etc. I always felt that learning a general purpose editor, and learning it very well, is more interesting than learning an IDE for one specific platform (VS.NET in this case).&lt;/p&gt;

&lt;p&gt;&lt;a href="http://twitter.com/stijnbe"&gt;One of my new colleagues&lt;/a&gt; recommended me to use NetBeans for PHP development, so I had a look at it. While I'm sure it has a lot to offer, it just didn't feel like the tool I wanted to use. Obviously I had also installed jEdit. While I have always loved jEdit, somehow I wasn't convinced anymore. I also had a look at gEdit, which certainly has potential if you install some extra plugins and configure it, but compared to other editors and IDE's it seems to be rather limited. So then there was still that other editor. The editor which has fascinated me since at least 5 years. The editor which I have been using from time to time to make small edits on config files. The one editor which has a history which dates back to 1976. Yes, indeed, I'm talking about &lt;a href="http://en.wikipedia.org/wiki/Vi"&gt;vi&lt;/a&gt; and it's modern incarnation &lt;a href="http://www.vim.org/"&gt;vim&lt;/a&gt; (Vi IMproved).&lt;/p&gt;

&lt;p&gt;As I already mentioned I had been using vi for at least 5 years to make small changes to config files, mostly over SSH on webservers, so I knew the basics. But the basics are, imho, just not enough to do some serious development. Therefore I decided to try and learn at least one new thing about vim everyday. Be it a new shortcut, a plugin, whatever. Reading an entire article with lots and lots of vim-shortcuts really isn't the best method to learn vim, because it's impossible to memorize them all at once.&lt;/p&gt;

&lt;p&gt;However after using other editors and IDE's, such as VS.NET, for so many years, it is difficult to just start with vim, because it has a steep learning curve. By example, I got used to navigating code with the arrow keys, certainly in combination with the control and shift keys, to move the cursor by words and select text. Because I did not yet know the correct vim keys and learning them all at once is impossible I had to find a solution to ease my transition. I found this solution in the mswin.vim script which comes with vim by default. You can enable this script by placing the following lines in your .vimrc file:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;source $VIMRUNTIME/mswin.&lt;span class="k"&gt;vim&lt;/span&gt;
behave mswin
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;This script makes vim behave more like other text editors. It's Vim with bicycle training wheels. You will be able to select text by using the arrow-keys in combination with shift, copy and paste with &amp;lt;CTRL+C&amp;gt; and &amp;lt;CTRL+V&amp;gt;, save with &amp;lt;CTRL+S&amp;gt; etc. Sadly it also uses some bindings, like &amp;lt;CTRL+Y&amp;gt;, which have, by default in vim, a different function thus making those default commands unavailable. While this script is very useful, my goal has always been to learn the real vi-shortcuts so in the end it should be possible to disable the script. You don't keep your training wheels either do you? And a few days ago I learned how to copy/paste from the global clipboard, which I believe was the last shortcut I was missing, so as of yesterday I have disabled the script. Now I hope I don't crash on my face because of the missing wheels :).&lt;/p&gt;

&lt;p&gt;Another nice trick I found is to change the color of the statusline depending on the current status. When I'm in normal mode, my statusline is gray, the default for the Mustang colorscheme. But while I'm in insert mode the statusline turns green. To configure this add the following lines to your .vimrc:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c"&gt;&amp;quot; first make sure the statusline is always shown&lt;/span&gt;
&lt;span class="k"&gt;set&lt;/span&gt; &lt;span class="nb"&gt;laststatus&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="m"&gt;2&lt;/span&gt;
&lt;span class="c"&gt;&amp;quot; then define two autocommands&lt;/span&gt;
&lt;span class="k"&gt;au&lt;/span&gt; &lt;span class="nb"&gt;InsertEnter&lt;/span&gt; * &lt;span class="k"&gt;hi&lt;/span&gt; StatusLine &lt;span class="nb"&gt;term&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;reverse guibg&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="mh"&gt;#005000&lt;/span&gt;
&lt;span class="k"&gt;au&lt;/span&gt; &lt;span class="nb"&gt;InsertLeave&lt;/span&gt; * &lt;span class="k"&gt;hi&lt;/span&gt; StatusLine &lt;span class="nb"&gt;term&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;reverse guibg&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="mh"&gt;#444444&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Please not that this configuration only works for gVim, not the terminal version. But it is possible to adapt it for the terminal version as well.&lt;/p&gt;

&lt;p&gt;Oh and just as a reference, here are some of the shortcuts I use to replace most of the shortcuts in other editors:
&lt;ul&gt;
  &lt;li&gt;&lt;b&gt;w&lt;/b&gt;: move to the next word (replaces &amp;lt;CTRL+Right Arrow&amp;gt;)&lt;/li&gt;
  &lt;li&gt;&lt;b&gt;b&lt;/b&gt;: move to the previous word (replaces &amp;lt;CTRL+Left Arrow&amp;gt;)&lt;/li&gt;
  &lt;li&gt;&lt;b&gt;de&lt;/b&gt;: delete the next word (replaces &amp;lt;CTRL+DELETE&amp;gt;)&lt;/li&gt;
  &lt;li&gt;&lt;b&gt;db&lt;/b&gt;: delete the previous word (replaces &amp;lt;CTRL+BACKSPACE&amp;gt;)&lt;/li&gt;
  &lt;li&gt;&lt;b&gt;viw&lt;/b&gt;: select entire word (replaces &amp;lt;CTRL+SHIFT+Right Arrow&amp;gt;) Note: keep pressing 'w' to select additional words&lt;/li&gt;
  &lt;li&gt;&lt;b&gt;"+p&lt;/b&gt;: paste from the global clipboard (replaces &amp;lt;CTRL+V&amp;gt; in case you want to paste text from another application)&lt;/li&gt;
  &lt;li&gt;&lt;b&gt;"+y&lt;/b&gt;: copy to the global clipboard (replaces  &amp;lt;CTRL+C&amp;gt; in case you want to copy text to another application)&lt;/li&gt;
  &lt;li&gt;&lt;b&gt;"+d&lt;/b&gt;: cut to the global clipboard (replaces  &amp;lt;CTRL+X&amp;gt; in case you want to cut text to another application)&lt;/li&gt;
&lt;/ul&gt;
&lt;/p&gt;

&lt;p&gt;I'm also using some very useful plugins to help me code, and I have some nice config-settings in my .vimrc, but i'll show these in another blogpost.&lt;/p&gt;</content><category term="coding"></category><category term="inuits-planet"></category><category term="learning"></category><category term="programming"></category><category term="vim"></category><category term="work"></category></entry><entry><title>ASP.NET MVC 1.0 Quickly</title><link href="https://budts.be/weblog/2009/02/aspnet-mvc-10-quickly" rel="alternate"></link><published>2009-02-18T18:06:00+01:00</published><updated>2010-12-18T12:31:00+01:00</updated><author><name>Jeroen Budts</name></author><id>tag:budts.be,2009-02-18:/weblog/2009/02/aspnet-mvc-10-quickly</id><summary type="html">&lt;p&gt;Today I was pretty surprised when going through my feeds to read that a friend of mine, Maarten Balliauw, &lt;a href="http://blog.maartenballiauw.be/post/2009/02/17/Announcing-my-book-ASPNET-MVC-10-Quickly.aspx"&gt;has a written a book&lt;/a&gt;. The title of the book is &lt;a href="https://www.packtpub.com/asp-net-model-view-controller-1-0-quickly/book"&gt;ASP.NET MVC 1.0 Quickly&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;It’s been quite a job, but there it is: Packt just announced my very first book on their site. It is titled “ASP.NET MVC 1.0 Quickly”, covering all aspects ASP.NET MVC offers in a to-the-point manner with hands-on examples. The book walks through the main concepts of the MVC framework to help existing ASP.NET developers to move on to a higher level. It includes clear instructions and lots of code examples. It takes a simple approach, thereby allowing you to work with all facets of web application development. Some keywords: Model-view-controller, ASP.NET MVC architecture and components, unit testing, mocking, AJAX using MS Ajax and jQuery, reference application and resources.&lt;/blockquote&gt;

&lt;p&gt;I always thought, and still think, that writing a book is a massive amount of work. Therefore i really …&lt;/p&gt;</summary><content type="html">&lt;p&gt;Today I was pretty surprised when going through my feeds to read that a friend of mine, Maarten Balliauw, &lt;a href="http://blog.maartenballiauw.be/post/2009/02/17/Announcing-my-book-ASPNET-MVC-10-Quickly.aspx"&gt;has a written a book&lt;/a&gt;. The title of the book is &lt;a href="https://www.packtpub.com/asp-net-model-view-controller-1-0-quickly/book"&gt;ASP.NET MVC 1.0 Quickly&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;It’s been quite a job, but there it is: Packt just announced my very first book on their site. It is titled “ASP.NET MVC 1.0 Quickly”, covering all aspects ASP.NET MVC offers in a to-the-point manner with hands-on examples. The book walks through the main concepts of the MVC framework to help existing ASP.NET developers to move on to a higher level. It includes clear instructions and lots of code examples. It takes a simple approach, thereby allowing you to work with all facets of web application development. Some keywords: Model-view-controller, ASP.NET MVC architecture and components, unit testing, mocking, AJAX using MS Ajax and jQuery, reference application and resources.&lt;/blockquote&gt;

&lt;p&gt;I always thought, and still think, that writing a book is a massive amount of work. Therefore i really have a lot of respect for people that have the courage to actually write a real book.&lt;/p&gt;

&lt;p&gt;In his blogpost Maarten explains why and how he wrote the book. According to his time tracking software, it took him 100 hours to write the book, which is far less than i would expect. On the other side, if you can only use spare time to do the work, it is a lot of time. Maarten also explains that he used Subversion to keep his work versioned and that some people laughed at him for doing so. I don't think this is such a strange idea. If I ever would write a book (consider the chances small...), I certainly would use Subversion, or a similar tool, to store my work. In fact, when my girlfriend wrote her paper for her last schoolyear I also made her use Subversion to store her word-documents. But i do find it strange that you write a complete book in Word (which is a word processor btw, not a text editor ;) ).&lt;/p&gt;

&lt;p&gt;I'm very curious to see and read the book. Btw Maarten, is that your own pair of glasses on the cover? Anyway, Congrats Maarten!&lt;/p&gt;</content><category term="Computer"></category><category term=".net"></category><category term="books"></category><category term="en"></category><category term="friends"></category><category term="programming"></category></entry></feed>