<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-3941948736831592480</id><updated>2012-02-12T01:43:13.479-05:00</updated><category term='trunk'/><category term='postgresql'/><category term='vi'/><category term='activestate'/><category term='hex'/><category term='auto_now'/><category term='hexadecimal'/><category term='django'/><category term='DateTIme'/><category term='processlist'/><category term='psql'/><category term='int'/><category term='binary'/><category term='pgsql'/><category term='search and replace'/><category term='auto_now_add'/><category term='editor'/><category term='komodo'/><category term='sql'/><category term='python'/><category term='komodo ide'/><category term='freebsd 7.0'/><category term='freebsd'/><category term='vim'/><category term='integer'/><category term='decimal'/><category term='ide'/><category term='komodo edit'/><title type='text'>Xbito Tech Blog</title><subtitle type='html'>My technology blog. Reviews, tips and comments by a geek.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://xbitotech.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://xbitotech.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Fernando Gutierrez</name><uri>http://www.blogger.com/profile/03674595530591151310</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/_7iobj_MW_BE/S_xPw63m8hI/AAAAAAAAAFs/0cvjD0YGjfI/s1600-R/n606800607_5145.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-3941948736831592480.post-9216469804794881203</id><published>2007-11-26T14:56:00.000-05:00</published><updated>2007-11-28T20:12:01.210-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='pgsql'/><category scheme='http://www.blogger.com/atom/ns#' term='processlist'/><category scheme='http://www.blogger.com/atom/ns#' term='psql'/><category scheme='http://www.blogger.com/atom/ns#' term='postgresql'/><title type='text'>Viewing current PostgreSQL Queries</title><content type='html'>I am a heavy MySQL user, so I constantly use a SHOW PROCESSLIST; to view how my developers or software are using the test database server. So now that we have more than one project using postgresql and since locking down the cpu is becoming more and more common I had to figure out a way to view the queries that are being executed on PostgreSQL.&lt;br /&gt;&lt;br /&gt;I found this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;SELECT * FROM pg_stat_activity;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;but since PostgreSQL turns off the storing of query strings all I could see was who where using the databse. So in the postgresql.conf file (in FreeBSD that's in /usr/local/pgsql/data/postgresql.conf) i just uncommented and edited the line with this option:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;stats_command_string = true&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Then just restart the postgresql and it is ready!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3941948736831592480-9216469804794881203?l=xbitotech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://xbitotech.blogspot.com/feeds/9216469804794881203/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3941948736831592480&amp;postID=9216469804794881203' title='40 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default/9216469804794881203'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default/9216469804794881203'/><link rel='alternate' type='text/html' href='http://xbitotech.blogspot.com/2007/11/viewing-current-postgresql-queries.html' title='Viewing current PostgreSQL Queries'/><author><name>Fernando Gutierrez</name><uri>http://www.blogger.com/profile/03674595530591151310</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/_7iobj_MW_BE/S_xPw63m8hI/AAAAAAAAAFs/0cvjD0YGjfI/s1600-R/n606800607_5145.jpg'/></author><thr:total>40</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3941948736831592480.post-3944731436513572634</id><published>2007-10-30T23:02:00.000-05:00</published><updated>2007-10-30T23:43:54.090-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='decimal'/><category scheme='http://www.blogger.com/atom/ns#' term='int'/><category scheme='http://www.blogger.com/atom/ns#' term='binary'/><category scheme='http://www.blogger.com/atom/ns#' term='integer'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='hexadecimal'/><category scheme='http://www.blogger.com/atom/ns#' term='hex'/><title type='text'>Converting numerical bases in python</title><content type='html'>Working with hexadecimal, binaries, and other  bases is becoming common at work, at first we try to use custom functions to convert from and to some bases, especially hexadecimal. But other languages have built-in methods to do that conversion, and so python too.&lt;br /&gt;&lt;br /&gt;First to convert and hexadecimal &lt;span style="font-weight: bold;"&gt;string &lt;/span&gt;to an integer we use:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;int_number = int('ab1', 16)&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;/blockquote&gt;The variable int_number will be 2737. That is ab1 hex to integer conversion. Now what about the other way, integer to hexadecimal, that would be:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;&lt;blockquote&gt;&lt;/blockquote&gt;hex(int_number)&lt;/blockquote&gt;&lt;br /&gt;And that would return '0xab1'. Note that it returns a string and has the 0x notation, we could use that notation also in the first conversion like this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;int_number = int('0xab1', 16)&lt;br /&gt;&lt;br /&gt;&lt;/blockquote&gt;So as you can see we pass a parameter to the int function to indicate the base, if we dont pass any python assumes that we are using a 10 base. As you have also seen there is a hex built-in function but there is no binary, or any other base built-in, so since we work a lot with binary we built a small function to do the work. There are hundreds of ways to do this, using recursion, whiles, fors, lamdas, etc. We end up using this function:&lt;br /&gt;&lt;blockquote&gt;&lt;br /&gt;def dectobin(number):&lt;br /&gt;    if number &lt; 1:&lt;br /&gt;        return ""&lt;br /&gt;    else:&lt;br /&gt;        return dectobin(number / 2) + str(number &amp;amp; 1)&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;Hope this works for you.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3941948736831592480-3944731436513572634?l=xbitotech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://xbitotech.blogspot.com/feeds/3944731436513572634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3941948736831592480&amp;postID=3944731436513572634' title='33 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default/3944731436513572634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default/3944731436513572634'/><link rel='alternate' type='text/html' href='http://xbitotech.blogspot.com/2007/10/converting-numerical-bases-in-python.html' title='Converting numerical bases in python'/><author><name>Fernando Gutierrez</name><uri>http://www.blogger.com/profile/03674595530591151310</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/_7iobj_MW_BE/S_xPw63m8hI/AAAAAAAAAFs/0cvjD0YGjfI/s1600-R/n606800607_5145.jpg'/></author><thr:total>33</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3941948736831592480.post-6189635883145231317</id><published>2007-10-24T10:32:00.000-05:00</published><updated>2007-10-24T10:46:39.107-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='freebsd'/><category scheme='http://www.blogger.com/atom/ns#' term='freebsd 7.0'/><title type='text'>FreeBSD 7.0 Beta1 Available!</title><content type='html'>Since I first tried &lt;a href="http://www.freebsd.org/"&gt;FreeBSD&lt;/a&gt; on the server side I have a preference for it over Linux. I think it has superior performance, not that I have done any real benchmark but I have, sort of, felt it. Anyway some friends have done some &lt;a href="http://tabo.aurealsys.com/archives/2005/02/04/postgresql-freebsd-smp-and-vinum/"&gt;tests in the pas&lt;/a&gt;t, but tests or not I still think it is a rock solid OS. My experience comes from FreeBSD &lt;a href="http://www.freebsd.org/releases/4.11R/announce.html"&gt;4.11&lt;/a&gt; and &lt;a href="http://www.freebsd.org/releases/5.3R/announce.html"&gt;5.3&lt;/a&gt;, thos two versions were probably the best, now that they are both out of maintenance i use a mix between &lt;a href="http://www.freebsd.org/releases/5.5R/announce.html"&gt;5.5&lt;/a&gt; and &lt;a href="http://www.freebsd.org/releases/6.0R/announce.html"&gt;6.0&lt;/a&gt;. But for some reason those two versions have not been as solid as the 5.3 or 4.11 were. In most cases it was a hardware compatibility problem.&lt;br /&gt;&lt;br /&gt;Now &lt;a href="http://www.freebsd.org/news/newsflash.html#event20071022:01"&gt;FreeBSD 7.0&lt;/a&gt; is nearing its release, &lt;a href="http://www.freebsd.org/releases/7.0R/schedule.html"&gt;probably in December&lt;/a&gt; we will have a brand new FreeBSD. I expect to see better hardware support and much more stability in general. So in order to accomplish that I hope to test the new beta release and any other change in the future. Just hope to have some time at &lt;a href="http://www.aureal.com.pe/"&gt;work.&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3941948736831592480-6189635883145231317?l=xbitotech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://xbitotech.blogspot.com/feeds/6189635883145231317/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3941948736831592480&amp;postID=6189635883145231317' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default/6189635883145231317'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default/6189635883145231317'/><link rel='alternate' type='text/html' href='http://xbitotech.blogspot.com/2007/10/freebsd-70-beta1-available.html' title='FreeBSD 7.0 Beta1 Available!'/><author><name>Fernando Gutierrez</name><uri>http://www.blogger.com/profile/03674595530591151310</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/_7iobj_MW_BE/S_xPw63m8hI/AAAAAAAAAFs/0cvjD0YGjfI/s1600-R/n606800607_5145.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3941948736831592480.post-2108105579756866531</id><published>2007-10-23T23:38:00.000-05:00</published><updated>2007-10-23T23:57:55.229-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ide'/><category scheme='http://www.blogger.com/atom/ns#' term='vim'/><category scheme='http://www.blogger.com/atom/ns#' term='komodo edit'/><category scheme='http://www.blogger.com/atom/ns#' term='editor'/><category scheme='http://www.blogger.com/atom/ns#' term='komodo'/><category scheme='http://www.blogger.com/atom/ns#' term='activestate'/><category scheme='http://www.blogger.com/atom/ns#' term='komodo ide'/><title type='text'>Komodo Edit</title><content type='html'>As a developer I have been searching an editor or IDE that could adapt to every need I could have. This search has been frustrating and not productive. Finally I have accepted the fact that there is no tool that will accomplish what I expected so now I work with a combination of utilities and editors.&lt;br /&gt;&lt;br /&gt;Normally my developer time is spend in Linux, there I use gVim or &lt;a href="http://www.vim.org/"&gt;vim&lt;/a&gt;. Sometimes when I have to work from home or a client I do it on my laptop that runs Windows Vista. There I recently have been using &lt;a href="http://www.activestate.com/Products/komodo_edit/"&gt;Komodo Edit&lt;/a&gt;. In the search for the perfect IDE I have seen &lt;a href="http://www.activestate.com"&gt;ActiveState&lt;/a&gt; &lt;a href="http://www.activestate.com/Products/komodo_ide/"&gt;Komodo IDE&lt;/a&gt; tons of times, but it is available freely only as a &lt;a href="http://www.activestate.com/store/komodo_ide/Trial/"&gt;Demo&lt;/a&gt;. Now ActiveState has released Komodo Edit completely &lt;a href="http://www.activestate.com/store/komodo_edit"&gt;for free&lt;/a&gt; and it comes with a &lt;a href="http://www.activestate.com/Products/komodo_edit/features.plex"&gt;set of features&lt;/a&gt; that covers my needs.&lt;br /&gt;&lt;br /&gt;Also Komodo Edit can be extended using xpi files (the same as Mozilla Firefox and Thunderbird). And there is a &lt;a href="http://community.activestate.com/addons"&gt;community site&lt;/a&gt; where you can find this extensions. There are few extensions available now, but when the userbase grows I'm sure they will grow in number.&lt;br /&gt;&lt;br /&gt;The features I use more or love more are autocomplete, the calltips, the Django syntax highlighting, block ident/unident, block comment/uncomment, and the multi-edit capability. Even though the space in the laptop screen is reduced (13" compared to the 19" + 19" + 17" that I use at my desktop), I can navigate with very little effort through all my code.&lt;br /&gt;&lt;br /&gt;There is even a vim emulation mode! I haven't tried it yet, but for heavy vi users it could be a choice if you wish to explore other editors. There is a linux version but for now I still prefer to use only gVim. It is enough.&lt;br /&gt;&lt;br /&gt;So the search is over for now, maybe in a couple of months I will go back to the search of the perfect tool, but for now I think I can use this tools and be productive enough.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3941948736831592480-2108105579756866531?l=xbitotech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://xbitotech.blogspot.com/feeds/2108105579756866531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3941948736831592480&amp;postID=2108105579756866531' title='33 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default/2108105579756866531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default/2108105579756866531'/><link rel='alternate' type='text/html' href='http://xbitotech.blogspot.com/2007/10/komodo-edit.html' title='Komodo Edit'/><author><name>Fernando Gutierrez</name><uri>http://www.blogger.com/profile/03674595530591151310</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/_7iobj_MW_BE/S_xPw63m8hI/AAAAAAAAAFs/0cvjD0YGjfI/s1600-R/n606800607_5145.jpg'/></author><thr:total>33</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3941948736831592480.post-226315684057660594</id><published>2007-10-20T04:48:00.000-05:00</published><updated>2007-10-20T07:56:32.248-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='auto_now_add'/><category scheme='http://www.blogger.com/atom/ns#' term='django'/><category scheme='http://www.blogger.com/atom/ns#' term='auto_now'/><category scheme='http://www.blogger.com/atom/ns#' term='DateTIme'/><category scheme='http://www.blogger.com/atom/ns#' term='trunk'/><title type='text'>Django Date Added and Modified</title><content type='html'>There has been some discussions in the django-developers list about removing auto_now and auto_now_add helpers for the date related fields. Since this functionality is very useful in those discussions some methods has been suggested, but i think that there has been no further advance in this subject.&lt;br /&gt;&lt;br /&gt;For a new project I have been working on we are using trunk code and we want to be sure that for the launch date we still have full functionality, so we created 2 custom fields in order to be able to use them directly on the models and have the desired values automatically set. They work for DateTimeFields only, but the idea could be used also for DateFields.&lt;br /&gt;&lt;br /&gt;In a file named fields.py we put this:&lt;br /&gt;&lt;pre&gt;from django.db import models&lt;br /&gt;import datetime&lt;br /&gt;&lt;br /&gt;class AddedDateTimeField(models.DateTimeField):&lt;br /&gt;    def get_internal_type(self):&lt;br /&gt;        return models.DateTimeField.__name__&lt;br /&gt;    def pre_save(self, model_instance, add):&lt;br /&gt;        if model_instance.id is None:&lt;br /&gt;            return datetime.datetime.now()&lt;br /&gt;        else:&lt;br /&gt;            return getattr(model_instance, self.attname)&lt;br /&gt;           &lt;br /&gt;&lt;br /&gt;class ModifiedDateTimeField(models.DateTimeField):&lt;br /&gt;    def get_internal_type(self):&lt;br /&gt;        return models.DateTimeField.__name__&lt;br /&gt;    def pre_save(self, model_instance, add):&lt;br /&gt;        return datetime.datetime.now()&lt;/pre&gt;&lt;br /&gt;Then in any models file we can import them and just use! Something like this for example:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;class Location(models.Model):&lt;br /&gt;    """ Some place's ubication """&lt;br /&gt;    name = models.CharField(_('Name'), maxlength=64, blank=False)&lt;br /&gt;    date_added = AddedDateTimeField(_('Date added'), editable=False)&lt;br /&gt;    date_modified = ModifiedDateTimeField(_('Date modified'), editable=False)&lt;br /&gt;    &lt;/pre&gt;I hope the community finds this useful!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3941948736831592480-226315684057660594?l=xbitotech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://xbitotech.blogspot.com/feeds/226315684057660594/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3941948736831592480&amp;postID=226315684057660594' title='159 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default/226315684057660594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default/226315684057660594'/><link rel='alternate' type='text/html' href='http://xbitotech.blogspot.com/2007/10/django-date-added-and-modified.html' title='Django Date Added and Modified'/><author><name>Fernando Gutierrez</name><uri>http://www.blogger.com/profile/03674595530591151310</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/_7iobj_MW_BE/S_xPw63m8hI/AAAAAAAAAFs/0cvjD0YGjfI/s1600-R/n606800607_5145.jpg'/></author><thr:total>159</thr:total></entry><entry><id>tag:blogger.com,1999:blog-3941948736831592480.post-3123810884897008605</id><published>2007-10-18T21:40:00.000-05:00</published><updated>2007-10-18T23:37:12.483-05:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='vi'/><category scheme='http://www.blogger.com/atom/ns#' term='vim'/><category scheme='http://www.blogger.com/atom/ns#' term='komodo edit'/><category scheme='http://www.blogger.com/atom/ns#' term='django'/><category scheme='http://www.blogger.com/atom/ns#' term='search and replace'/><category scheme='http://www.blogger.com/atom/ns#' term='komodo'/><title type='text'>Search and Replace in Vi</title><content type='html'>&lt;a href="http://www.aureal.com.pe/"&gt;We&lt;/a&gt; are working at a client adapting an already developed project so they can do their work with it. The project was developed using &lt;a href="http://www.djangoproject.com/"&gt;django&lt;/a&gt;, first with &lt;a href="http://www.djangoproject.com/download/0.91/tarball/"&gt;0.91&lt;/a&gt;, then with &lt;a href="http://www.djangoproject.com/download/0.95/tarball/"&gt;0.95&lt;/a&gt;, now we are going to use &lt;a href="http://code.djangoproject.com/svn/django/trunk/"&gt;svn trunk&lt;/a&gt;. So one of the things that we are using, and a lot, is just plain search and replace. I am currently developing a lot on my Vaio Laptop, using Windows Vista as OS, and &lt;a href="http://www.activestate.com/Products/komodo_edit/"&gt;Komodo Edit&lt;/a&gt; as editor. It has great Find and Replace capabilities, well really i don't know if that could be complicated.&lt;br /&gt;&lt;br /&gt;So, the server is a &lt;a href="http://www.centos.org/"&gt;Centos 4&lt;/a&gt;, some problemas with the drivers didn't allow us to use our classic &lt;a href="http://www.freebsd.org/"&gt;FreeBSD&lt;/a&gt;, we are still dealing with the issues of using &lt;a href="http://www.python.org/"&gt;python&lt;/a&gt; 2.3 instead of 2.4 which we are used to. So that and the trunk thing are the main reasons to do a lot of searching and replacing.&lt;br /&gt;&lt;br /&gt;A great deal of deveolpment is done at a workstation, there it was easy to follow the GUI and just point and click. In Centos it is another story, I use vi or &lt;a href="http://www.vim.org/"&gt;vim&lt;/a&gt; normally, even at my workstation at Aureal I use gvim and I love it. But the thing I never learned was to search and replace using plain vi commands. To make things worse I have, like, 2 or 3 points of experience out of 100 in sed. So I knew that it had to be a similar syntax, the classic:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;:s/oldstring/newstring/g&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;So I tried that, but no, it worked only to replace the oldstring in the current line, that was not what I wanted. So once again google knows it all. It gave me the simple and expected answer in the first returned link. It confirmed that the above string just replaces oldstrings in the current line. But, as vi is a great great editor, you can give the command more parameters, so I learned that you could pass a range of line numbers to apply the search and replace, so I just thought that I could use something like this:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;:1,$s/oldstring/newstring/g&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;On a side note, I just recently learned that the $ means "last line". That really helps a lot! But it turns out that there is a shorter way to write this using:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;:%s/oldstring/newstring/g&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;So the % would be equivalent to "1,$".&lt;br /&gt;&lt;br /&gt;And thats it, I just learned that this week. And it is useful! I know, for a developer with 3 years of experience not knowing that would be like a sin, but I just never need it like a did today.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3941948736831592480-3123810884897008605?l=xbitotech.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://xbitotech.blogspot.com/feeds/3123810884897008605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=3941948736831592480&amp;postID=3123810884897008605' title='82 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default/3123810884897008605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/3941948736831592480/posts/default/3123810884897008605'/><link rel='alternate' type='text/html' href='http://xbitotech.blogspot.com/2007/10/search-and-replace-in-vi.html' title='Search and Replace in Vi'/><author><name>Fernando Gutierrez</name><uri>http://www.blogger.com/profile/03674595530591151310</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/_7iobj_MW_BE/S_xPw63m8hI/AAAAAAAAAFs/0cvjD0YGjfI/s1600-R/n606800607_5145.jpg'/></author><thr:total>82</thr:total></entry></feed>
