Vim Tips of the Day: Moving and working with split windows

Jul
5
:vs <filename>   Open a file in vertical split window
:sp <filename>   Open a file in horizontal split window
Ctrl + ww             Switch between windows (in rotation)
Ctrl + wj               Switch to split window on the bottom
Ctrl + wk              Switch to split window on the top
Ctrl + wh              Switch to split window on the left
Ctrl + wl               Switch to split window on the right

-Edwin

Vim Tips of the Day: Format a Text Block to Wrap at Specified Width

Mar
1

At times I found that I needed to edit a text and auto-wrap doesn’t work automatically. So with this tip you can select the text you want to wrap, and Vim will wrap it for you. First, you need to set the text width size of your preference. I personally like to have 80 characters in width:

:set textwidth=80

If you put this on your .vimrc, everytime you type a new line of text, Vim automagically wrap your text when it reaches 80 characters. Beware that this option actually wrap your text by inserting line breaks. If this is not the behaviour you want, you can use ‘:set wrap’ option to let Vim only display text as wrap.

There are times when the ‘textwidth’ option doesn’t work automatically.. and when that happens, you can select the text you want to wrap (with Visual Mode: Shift + v), and type gq

source: StackOverflow

VIM Tips of the Day: Save a File with Root Permission without Re-opening the File

Mar
1

Tips of the day: courtesy of commandlinefu

Save a file in VIM with root permission without re-opening the file:

:w !sudo tee %

To do this silently, just pipe it to null like so:
:w !sudo tee % > /dev/null

xterm-clipboard support on Vim under Arch

Jul
15

I ran a system-upgrade on my Arch linux about 2 weeks ago and not until recently when I was using Vim heavily that I realized I lost my copy-paste support between vim instances on different terminal. I knew I solved this problem before but I just couldn’t remember how.

I finally found the solution and before I forget, I’m just going to share it here. This thread helped me.

Basically, vim that comes with Arch was compiled with minimal options. Some features (like xterm-clipboard support) are not included. The solution is to remove the default Vim and install GVim through pacman. GVim includes a richer-featured Vim. After that, don’t forget to insert below line on your ~/.vimrc:

set clipboard=unnamed

Completely Remove a File from a Git Repo

Apr
11

This guide helped me removing a file and its associated history from my git repo.

How to Kill a Great Idea

Mar
22

Friendster – One of the biggest tech flop since the dot-com bubble burst, a lesson to learn.

A Good Article on How to Become a Creative Software Developer (or in general)

Mar
16

I’ve been looking to improve my creativity lately when I stumbled upon this article on my RSS feeds:
http://softwarecreation.org/2010/how-to-become-an-expert-creativity/

I recently had an interview and the interviewer mentioned that I was lacking on creativity which he said is essential to a software developer, and then it hit me. I knew that it was not my greatest strength, but I constantly ignored it (as in not trying to improve it) just because I thought I have other qualities such as being knowledgeable. Perhaps this article is a start for me to develop my creativity skills.

Change Default Storage Engine in MySQL

Jan
30

I like my default engine to be InnoDB because it’s fully transactional and supports foreign key references. However, the default engine in MySQL is MyISAM.

There are several ways to change the default storage engine:

  1. Add default-storage-engine = innodb to your /etc/mysql/my.cnf under mysqld server section
  2. The default storage engine can be specified at server startup with the –default-storage-engine option.
  3. For a running server, an administrator who has the SUPER privilege can change the default storage engine globally for all clients by setting the global storage_engine system variable:
    SET GLOBAL storage_engine = innodb;

    Setting the storage engine this way affects any client that connects after the statement executes. Clients that are connected at the time of statement execution are unaffected.

  4. Any client can change its own default storage engine by issuing either of these statements:
    SET SESSION storage_engine = innodb;
    SET storage_engine = innodb;
    

If you change your default storage engine using Method 1, you can optimize the performance by adding few more instructions, as explained in this Stack Overflow post.

I use Method 1, and I added 3 lines to my /etc/mysql/my.cnf:

Under [mysqld] :

default-character-set = utf8
default-storageengine = innodb

… then I also added this line in InnoDB section:

innodb_buffer_pool_size = 512M

Removing Your Site from Search Engine Crawler

Jan
30

Don’t want search engine like Google to include your site in the search results?

Create a file called “robots.txt” on your root HTML directory, the path where your main site’s URL belongs: http://www.yoursite.com/

This is normally located in www directory or public_html.

In this file, add these lines:

User-agent: *
Disallow: /

“Disallow” property indicates the path that you don’t want to be crawled/searched by search engines, including its child URL. In the example above, your site will be completely removed from search engine results as the main URL is disallowed.

If you want to exclude only certain child URLs, you can do write something like this:

User-agent: *
Disallow: /about
Disallow: /secret

My config files are now up in GitHub!

Jan
16

I’m sharing my config files on my Arch linux, which include settings for:

  • vim
  • bash
  • X11
  • awesome window manager

You can clone them from here.