Sunday, December 15, 2013

gvim font style and size

Put this in your .gvimrc file:

if has("gui_running")
  if has("gui_gtk2")
    set guifont=Inconsolata\ 16
  elseif has("gui_macvim")
    set guifont=Menlo\ Regular:h18
  elseif has("gui_win32")
    set guifont=Consolas:h11:cANSI
  endif
endif

This sets the font style and size depending on which environment you are running.  For example, I am running Mac OSX so my font is set to "Menlo Regular:h18".

Select your preferred font by looking at Edit | Font | Show Fonts
To reveal what that means to gvim, run this within gvim:

:set gfn?

For example, if I use the graphical menu to select "English Andale Mono | Regular | 24", the command "set gfn?" would reveal "guifont=Andale Mono:h24"

With that knowledge, we can craft what font we need to provide in the .gvimrc file from above.  Escape spaces with a backslash, so we get:

Andale\ Mono:h24

So my .gvimrc script line would read:

set guifont=Andale\ Mono:h24


Tuesday, December 10, 2013

Mac OSX bash prompt

Put this in .bash_profile

export PS1="\w\$ "

This will considerably shorten your bash prompt to display only the working directory instead of the default which also displays computer name and user name.

We can display those as well by playing around with the defaults:

PS1='\h:\W \u\$ '

\h = First part of host name
\W = Directory name (notice this is uppercase rather than the lowercase I used above.  Lowercase w means the entire directory path; uppercase W means just the working directory)
\u = Username
\$ = If not root, display $ (otherwise display #)

There are other "magic" symbols that can be used - see http://www.ibm.com/developerworks/linux/library/l-tip-prompt/


Thursday, December 5, 2013

Turn off bells in Vim

:set visualbell

This tells Vim to flash the screen instead of ringing a bell.

To make it permanent, put it in your .vimrc file:


set visualbell



Wednesday, December 4, 2013

How to insert/remove comments in Vim

Insert comments (for example, the "#" symbol):

Go to the line you want to comment.
Press CTRL-V (might be CTRL-Q in Windows because of shortcut conflict)
Cursor to the last line
Press I, #, [Esc]
("I", then "#", then "Escape")
(Case matters.  Uppercase "I", not lowercase "i")




Remove comments:

Go to the line you want to comment.
Press CTRL-V (might be CTRL-Q in Windows because of shortcut conflict)
Cursor to the last line
Press x


How to update Ubuntu

sudo apt-get update
sudo apt-get upgrade

and sometimes

sudo apt-get dist-upgrade

Tuesday, December 3, 2013

Monday, December 2, 2013

How to reset a Rails database

bundle exec rake db:reset
bundle exec rake test:prepare


May have to restart the Rails web server.