Wednesday, October 28, 2009

Daily VIM commands

These are commands I found to be using frequently when on command line:

Window Operations:
  • :split - horizontal split
  • :vs - vertical split
  • :vsplit - vertical split
  • Ctrl + W, Ctrl + W - will tab between windows
  • Ctrl + W, _ - will maximize current window
  • Ctrl + W, = - will resize all windows equally
  • 4 CTRL-W + - will increase height of window by 4 lines
File Explorer:
  • :e - will tab through the files available in current directory
  • :cd <..> - will change to directory, just like system command
  • :Ex - open file explorer in current window
  • :Sex - split current window and open explorer in one of windows
  • Hit a file to open that file in current window
  • Ctrl + 6 to go back to explorer from opened file
Search/Replace
  • :s/OLD/NEW - find and replace a first occurrence on current line
  • :s/OLD/NEW/g - find and replace all occurrences on current line
  • :%s/OLD/NEW/g - find and replace all occurrences in entire file
Diffing files
  • From within VI: :vertical diffsplit file
  • From command shell: vimdiff file1, file2
Buffer Operations
  • :ls - will list currently open buffers
  • :bn - will open a buffer n, where n is a number as reported by ls
  • :b - tab through open buffers, select one to open with Enter
Tabs
  • :tabe - opens a new tab (tab in edit mode)
  • gt - advance to the next
  • gT - advance to the previous
  • {count}gt - go to the {count} tab
  • :tabe - path/to/file - to open a file
  • :tabn - go to next tab
External Commands
  • :pwd - print working directory
  • :cd - as usual - move to directory
  • :cd D - will iterate through directories starting with D

Visual Selection Mode
  • v - to put in the visual selection mode
  • y - yank/copy
  • x - cut selection
  • p - paste at cursoe location


Autosuggest
Ctrl + N or Ctrl + P - this will show choices when typing partial working


Expand tabs with spaces(put these onto the .vimrc file):
:set tabstop=4
:set expandtab
:%retab

Mouse Support (in the .vimrc file)
:set mouse=a


This is mostly a cheet sheet for myself, ..but enjoy
igor

Sunday, October 18, 2009

Ubuntu 9.04 on MacBook Pro 5.4

A few days ago I purchased a new shiny MacBook Pro, and decided to install Ubuntu on it. Why? because Linux is my habitat, and also because some software packages I use are readily available on Linux, but not on Mac OS. In any case, this blog is not about Mac OS vs Linux (more on this maybe one day; I can write a book on how Mac OS sucks :)), but rather some steps I had to overcome to complete the installation.

Out of the box, Jaunty works on MBP, with some exceptions. The trackpad is too slow be useful, the Fn key in in the reverse.
After installation using the Boot Camp, I followed the instructions on the Ubuntu forums: https://help.ubuntu.com/community/MacBookPro5-1_5-2/Jaunty, additionally used information here: https://help.ubuntu.com/community/AppleKeyboard
to adjust keyboard settings. All was fine, except the Trackpad refused to be configured. This has proven to be the biggest hurdle I spent the most time on... until I discovered this posting:
Configure ALPS (Synaptics) touchpad in Ubuntu 9.0.4 (Jaunty Jackalope)
Apparently, the fdi file must be mapped to the correct HAL device (kinda makes sense :)).
Using this command:

$lshal > hal.txt

, I was able to see that the name of my device was: "Apple Inc. Apple Internal Keyboard / Trackpad".
Armed with this knowledge, I edited my FDI file to my liking, and HAL was able to load it, and apply my settings to the right device.
The trick is to find the parameter: "info.product" in the lshal output and use it in the fdi file.
Here is my complete fdi file after adjusting speed and sensitivity:

http://igorpolevoy.com/public/attach/Ubuntu9.04OnMacBookPro/x11-synaptics-bcm5974.fdi

cheers,
igor