November 22, 2011

Dokumentasi Upgrade Debian Squeeze ke Wheezy/sid


Hal yang harus dipersiapkan saat upgrade Squeeze ke Wheezy:

  • Pertimbangkan kenapa anda harus melakukan update ke rilis testing.
  • Backup data-data penting
  • Persiapkan linux liveusb/bootable CD
  • Cari referensi sebanyak-banyaknya untuk persiapan jika kemungkinan terburuk terjadi saat proses upgrade (meskipun testing aman digunanan)
  • Pilih mirror yang dekat secara geografis dari tempat tinggal
  • Yakin dan tahu apa yang harus dilakukan. Linux tidak semudah windows, tapi jika anda terbiasa denganl inux, memakai linux jauh lebih mudah daripada windows.
  • Baca dan pilih dengan seksama perintah yang keluar. Akan ada beberapa opsi yang harus anda pilih antara lain Yes/No/Default/Different
  • Proses upgrade butuh usaha yang lebih daripada saat install. Tapi bukan berarti harus memilih fresh install saat gagal upgrade.

Contoh mirror yang saya pakai:
# deb http://security.debian.org/ squeeze/updates main contrib
# deb-src http://security.debian.org/ squeeze/updates main contrib
# deb http://kambing.ui.ac.id/debian/ squeeze main contrib non-free
deb http://kambing.ui.ac.id/debian/ wheezy main contrib non-free

Perintah yang digunakan:
# apt-get update
# apt-get --show-upgraded dist-upgrade

Jika ada masalah, perintah selanjutnya
# apt-get -f install

Setelah itu jalankan lagi perintah
# apt-get dist-upgrade

Untuk informasi, ketikkan:
$ cat /etc/debian_version
$ uname -a

Saat proses upgrade gagal:

  • Jangan panik, ketikkan saja masalah yang anda hadapi di Google. Pasti ada yang pernah mengalami masalah yang sama.
  • Pada synaptic, broken package ditandai dengan warna merah. Disana tersedia info dependency apa saja yang dibutuhkan/conflict dengan broken package
  • Jika anda punya waktu, berusahalah minimal satu hari sebelum memilih fresh install.
  • Jika komputer gagal booting, gunakan liveusb/bootable CD yang dipersiapkan untuk trouble shooting.
  • Copy semua file yang telah anda download di /var/cache/apt/archives/ ke salah satu folder. Anda akan memakainya lagi saat penasaran pengen update lagi. Daripada harus download dari awal.
  • Jika anda malas konfigurasi, copy semua hidden file di /home/username/ tempatkan di folder backup. Nantinya anda tinggal mengembalikan lagi ke tempat semula setelah selesai install ulang. Dengan catatan harus disesuaikan dengan kebutuhan.


Saat proses upgrade berhasil:
- Jika kapasitas harddisk sangat minim, hapus kernel lama yang sudah tidak
  dipakai, tapi sisakan minimal satu.
- Cari dan hapus semua file konfigurasi yang sudah tidak terpakai
# aptitude search '~c'
# aptitude purge '~c'

Beberapa hari yang lalu saya melakukan upgrade, tapi gagal karena paket libc6 yang saya pake versi ubuntu. Sedangkan libc6 ini paket yang sangat vital dan menghambat proses upgrade. Saya punya koleksi repository Debian dan Ubuntu. Karena waktu release Debian yang lama dan koneksi internet yang lambat, saya pernah memakai file repo ubuntu untuk upgrade beberapa aplikasi.

Akhirnya, setelah dua tahun gak pernah install ulang, saya terpaksa fresh install karena saya gak berhasil ketemu jawabannya dan komputer harus segera dipake. DVD installer saya Lenny, punya repository Squeeze lengkap, dan sudah download paket Wheezy. Dalam waktu satu jam saya install Lenny, upgrade Squeeze, kemudian Wheezy/sid lancar tanpa ada masalah.

August 24, 2011

120+ Perintah VIM dan Fungsinya



Banyak yang bilang kalau vim (dan emacs) adalah text editor yang wajib dipelajari para pengguna linux. Minimal tau cara membuka file, edit beberapa text dan keluar dari vim.

Dulu saya gak terlalu tertarik memakai vim, bahkan sering dibuat jengkel karena untuk memindah kursor saja harus belajar, harus ada insert dan command mode. Tapi setelah membaca beberapa artikel tentang vim, saya mulai tertarik untuk mempelajari lebih jauh, semakin menarik. Apalagi setelah menambahkan plugin dan beberapa baris konfigurasi di vimrc. Buat yang baru mengenal vim, coba ketik "vimtutor" di terminal, tutorial praktek vim yang sangat keren.

Setelah itu silahkan baca kitab vim yang direkomendasikan para veteran vim judulnya "Learning the Vi and Vim Editor" terbitan O'Reilly Media,Inc, karangan Arnold Robbins, Elbert Hannah dan Linda Lamb.

Berikut 120+ perintah vim yang saya rangkum dari berbagai sumber dan sudah saya terjemahkan ke bahasa nasional kita, bahasa indonesia. Gak perlu dihafalin, karena semakin kita bersahabat dengan vim, jari tangan kita akan ingat dengan sendirinya.
    +------------------------------------------------------------------+
    |  Ada beberapa perintah yang sebenarnya merupakan multi-command,  |
    |  misalnya:                                                       |
    |  --------------------                                            |
    |  ggguG = lowercase                                               |
    |  --------------------                                            |
    |  gg : memindah kursor ke baris pertama                           |
    |  gu : mengganti dengan huruf kecil                               |
    |  g  : memindah kursor ke baris terakhir                          |
    |  --------------------                                            |
    |  ggVG = seleksi semua                                            |
    |  --------------------                                            |
    |  gg: memindah kursor ke baris pertama                            |
    |  v : mode visual                                                 |
    |  g : memindah kursor ke baris terakhir                           |
    |  --------------------------------------------------------------  |
    |  Trik : lakukan mapping pada vimrc  untuk multi-command yang     |
    |  sering digunakan,misalnya:                                      |
    |                                                                  |
    |  map  ggVG                                                  |
    |                                                                  |
    |  (Control + a) akan menyeleksi semua text dari baris pertama     |
    |  sampai terakhir,seperti text editor pada umumnya.               |
    +------------------------------------------------------------------+

===============================================================================
MEMBUKA FILE, MENYIMPAN DAN KELUAR
===============================================================================
:e namafile     : membuka file bernama "namafile",apabila tidak ditemukan maka
                  akan di buat file baru dengan nama "namafile".
:browse e       : membuka file dengan tampilan grafis
:Sex            : membagi window dan membuka file explorer
:e              : memuat ulang file (reload)
:new filebaru   : mengedit "filebaru" di window baru
:w namafile     : menyimpan file dengan nama "namafile"
:w              : menyimpan file tanpa harus keluar dari ViM.
:qa             : keluar tanpa menyimpan semua perubahan jika buffer lebih dari 
                  satu
:q!             : keluar tanpa menyimpan perubahan.
:q              : keluar dari ViM.
ZZ              : menyimpan isi dari buffer kedalam file, kemudian keluar.

===============================================================================
KURSOR
===============================================================================
h               : geser kiri 1 karakter
j               : turun 1 baris
k               : naik 1 baris
l atau Spasi    : geser kanan 1 karakter
w               : geser kanan 1 kata (kursor pada huruf pertama)
W               : geser kanan 1 kata dan menghiraukan tanda baca
                  (kursor pada huruf pertama)
e               : geser kanan 1 kata (kursor pada huruf terakhir)
E               : geser kanan 1 kata dan menghiraukan tanda baca
                  (kursor pada huruf terakhir)
b               : geser kiri 1 kata (kursor pada huruf pertama)
B               : geser kiri 1 kata dan menghiraukan tanda baca
                  (kursor pada huruf pertama)
0 (angka nol)   : pindah ke awal baris
$               : pindah ke akhir baris
(               : pindah ke awal kalimat
)               : pindah ke akhir kalimat
{               : pindah ke awal paragraf
}               : pindah ke akhir paragraf
-               : pindah ke karakter pertama pada baris sebelumnya
+               : pindah ke karakter pertama pada baris selanjutnya
gg              : pindah ke baris pertama
G               : pindah ke baris terakhir
H               : layar atas
M               : layar tengah
L               : layar bawah
nG              : pindah ke baris "n"
ENTER           : turun 1 baris dan menempatkan kursor pada karakter pertama
Ctrl+F          : turun 1 halaman
Ctrl+B          : naik 1 halaman

    +-------------------------------------------------------------------+
    |  Pada beberapa perintah bisa dikombinasikan dengan angka, misal:  |
    |  17h,8j,19k,45l,17w,8E,1945G                                      |
    +-------------------------------------------------------------------+

===============================================================================
MENAMBAH TEXT / MASUK KE MENU INSERT
===============================================================================
i               : sebelum kursor
I               : awal baris
a               : setelah kursor
A               : akhir baris
o               : membuat baris baru diatas posisi kursor
O               : membuat baris baru dibawah posisi kursor

===============================================================================
EDIT TEXT
===============================================================================
s               : meng-edit satu (dan/atau menambahkan beberapa karakter) 
                  dimulai dari posisi kursor 
S               : hapus kemudian meng-edit satu baris dimana kursor berada
r               : meng-edit satu karakter pada posisi kursor (dari command mode)
R               : meng-edit karakter, dimulai dari posisi kursor (meng-edit 
                  karakter yang dilewati kursor sampai menekan ESC)
cb,cB,ce,cE,    : meng-edit text dikombinasikan dengan tombol motion (lihat
cw,cW,c(,c),      KURSOR)
c{,c},c0,c$

    +-------------------------------------------------------------------+
    |  Pada beberapa perintah bisa dikombinasikan dengan angka, misal:  |
    |  17c),c8G                                                         |
    +-------------------------------------------------------------------+

===============================================================================
HAPUS TEXT
===============================================================================
x               : menghapus karakter pada posisi kursor
dd              : menghapus baris
C               : menghapus sampai akhir baris dan masuk menu insert
D               : menghapus sampai akhir baris
db,dB,de,dE,    : mengganti text dikombinasikan dengan tombol motion (lihat 
dw,dW,d(,d),      KURSOR)
d{,d},d0,d$

    +-------------------------------------------------------------------+
    |  Pada beberapa perintah bisa dikombinasikan dengan angka, misal:  |
    |  17x,8dd,1945dw                                                   |
    +-------------------------------------------------------------------+

===============================================================================
COPY - PASTE
===============================================================================
yy              : meng-copy satu baris
nyy             : meng-copy "n" baris
Y               : meng-copy sampai akhir baris
p               : paste setelah atau di bawah baris posisi kursor
P               : paste tepat pada posisi kursor atau diatas baris

===============================================================================
MENCARI TEXT
===============================================================================
/asdf           : mencari "asdf" dari atas kebawah
?asdf           : mencari "asdf" dari bawah ke atas
*               : mencari kata dibawah posisi kursor
n               : mengulang pencarian terakhir
/jo[ha]n        : mencari john atau joan
/\          : mencari kata "indomie" atau "supermie"
/^\n\{3}        : mencari 3 baris yang kosong
y/              : highlight/block kata yang dicari

===============================================================================
MENGGANTI TEXT
===============================================================================
:s/lama/baru/g      : mennganti kata "lama" dengan kata "baru" dalam satu baris
:%s/lama/baru/g     : mengganti semua kata "lama" dengan kata "baru"
:%s/lama/baru/gc    : mengganti semua kata "lama" dengan kata "baru" dengan 
                      meminta konfirmasi terlebih dahulu
:%s/lama/baru/gi    : mengganti semua kata "lama" dengan kata "baru" tanpa 
                      menghiraukan huruf besar/kecil
:19,45s/lama/baru/g : mengganti semua kata "lama" dengan kata "baru", dimulai 
                      dari  baris 19 sampai dengan baris 45
:bufdo %s/lama/baru/g : mengganti kata "lama" dengan kata "baru" pada semua 
                        buffer yang terbuka

===============================================================================
CHANGE CASE
===============================================================================
VU              : mengubah baris menjadi huruf besar semua
Vu              : mengubah baris menjadi huruf kecil semua
vEU             : mengubah kata menjadi huruf besar
vEu             : mengubah kata menjadi huruf kecil
gggUG           : mengubah semua text menjadi huruf besar
ggguG           : mengubah semua text menjadi huruf kecil
vE~             : membalik kata dari huruf besar ke huruf kecil atau sebaliknya
g~~             : membalik baris dari huruf besar ke huruf kecil atau sebaliknya
:%s/\<./\u&/g   : mengubah huruf pertama dari setiap kata dengan huruf besar
:%s/\<./\l&/g   : mengubah huruf pertama dari setiap kata dengan huruf kecil
:%s/.*/\u&      : mengubah huruf pertama dari setiap baris dengan huruf besar
:%s/.*/\l&      : mengubah huruf pertama dari setiap baris dengan huruf kecil
:19,45s/.*/\l&  : mengubah huruf pertama dari baris 19 sampai baris 45 dengan 
                  huruf kecil
:%s/[.!?]\_s\+\a/\U&\E/g : mengubah huruf pertama dari setiap kalimat dengan 
                           huruf besar

===============================================================================
TAB
===============================================================================
:tabnew         : membuka tab baru
:tabfirst       : pindah ke tab pertama
:tablast        : pindah ke tab terakhir
:tabdo          : eksekusi perintah pada semua tab
:tab ball       : menempatkan semua file yang terbuka menjadi satu tab/satu file
   : pindah ke tab selanjutnya
 : pindah ke tab sebelumnya

===============================================================================
MEMBAGI WINDOW
===============================================================================
:split namafile : membuka file bernama "namafile" pada window terpisah
:vsplit         : membagi window secara vertikal
:hide           : menutup window
:sview namafile : seperti :split (read-only)
k       : meletakkan kursor pada window atas

===============================================================================
MENANDAI
===============================================================================
mn              : menandai posisi kursor dengan "n"
'n              : memindah posisi kursor ke tanda n

===============================================================================
AUTO COMPLETE
===============================================================================
    : melengkapi kata dengan yang pernah ditulis sebelumnya
    : melengkapi baris dengan yang pernah ditulis sebelumnya

===============================================================================
INDENT
===============================================================================
>>              : indent
        : indent
<<              : un-indent (insert mode)
        : un-indent (insert mode)
:17,45>         : indent baris 17 sampai 45

===============================================================================
INTERAKSI DENGAN UNIX
===============================================================================
:shell          : membuka terminal
        : kembali ke Vim
:!pwd           : eksekusi pwd dari Vim
!!pwd           : eksekusi pwd dan menyisipkan output di file

===============================================================================
LAIN-LAIN
===============================================================================
.               : mengulang perintah sebelumnya 
%               : pindah kursor ke sesama tanda kurung yang berpasangan (),{},[]
:his c          : menampilkan daftar perintah sebelumnya
:his s          : menampilkan daftar pencarian kata sebelumnya
:history        : menampilkan daftar perintah yang dilakukan sebelumnya
:ju             : menampilkan daftar pemindahan kursor sebelumnya
q:              : membuka window yang berisi daftar perintah sebelumnya
q/              : membuka window yang berisi daftar pencarian kata sebelumnya
g          : menampilkan informasi file (jumlah baris,kolom,kata,ukuran file)
:19,45TOhtml    : konversi baris 19 sampai 45 dalam bentuk html
:runtime! syntax/2html.vim : konversi file dalam bentuk html

August 19, 2011

vimrc

" Filename      : vimrc
" Description   : ViM Configuration File
" Maintainer    : Edi S. Adiatmojo <ediologi@gmail.com>
" Last Modified : 09 Aug 2011, 04:41am

"=============================== a-z ===================================
" FIRST SECTION "
"=======================================================================
set nocompatible " Bram Moolenaar suggests this as the first line of our vimrc
call pathogen#runtime_append_all_bundles()
call pathogen#helptags()
    " Use panthogen easily modify the runtime path to include all plugin
    " under the ~/.vim/bundle directory
    " run 'git submodule init && git submodule update'
    " every time a submodule is added.
set cpoptions=aABceFsmq
"             |||||||||
"             ||||||||+-- When joining lines, leave the cursor
"             |||||||       between joined lines
"             |||||||+--- When a new match is created (showmatch)
"             ||||||        pause for .5
"             ||||||+---- Set buffer options when entering the
"             |||||         buffer
"             |||||+----- Write command updates current file name
"             ||||+------ Automatically add <CR> to the last line
"             ||||          when using :@r
"             |||+------- Searching continues at the end of the match
"             |||           at the cursor position
"             ||+-------- A backslash has no special meaning in mappings
"             |+--------- :write updates alternative file name
"             +---------- :read updates alternative file name
set encoding=utf-8 " Sets the character encoding used in VIM
set fileencodings=utf-8 " Character encoding for the file of this buffer
set fileformats=unix,dos,mac " Support all three, in this order
set history=200 " Store 200 history (default is 20)
set noexrc " Don't use local version of .(g)vimrc, .exrc
set termencoding=utf-8 " Encoding used for the terminal
set ttyfast " We have a fast terminal connection


"=============================== a-z ===================================
" GENERAL SETTING "
"=======================================================================
autocmd BufWinEnter *.* silent loadview " Make VIM load view (state) (folds, cursor, etc)
autocmd BufWinLeave *.* mkview " Make VIM save view (state) (folds, cursor, etc)
filetype plugin indent on " Load filetype plugins/indent settings
set autochdir " Always switch to the current file directory
set backspace=indent,eol,start " Make backspace more flexible
set nobackup " No backup files, use modern ways
set clipboard+=unnamed " Share windows clipboard
set hidden " We can change buffers without saving
set iskeyword+=_,$,@,%,# " None of these are word dividers
set mouse=a " Use mouse everywhere
set noerrorbells " Silent please :)
set noswapfile " Do not write annoying swap files
set whichwrap=b,s,<,>,~,[,] " Everything wraps
"             | | | | | | |
"             | | | | | | +-- "]" Insert and Replace
"             | | | | | +---- "[" Insert and Replace
"             | | | | +------ "~" Normal
"             | | | +-------- <Right> Normal and Visual
"             | | +---------- <Left> Normal and Visual
"             | +------------ <Space> Normal and Visual
"             +-------------- <BS> Normal and Visual
set wildmenu " Turn on command line completion wild style
set wildignore=*.dll,*.o,*.obj,*.bak,*.exe,*.pyc,*.swp
                 \*.jpg,*.gif,*.png " Ignore these list file extensions
set wildmode=list:longest " Turn on wild mode huge list
set winaltkeys=no " ALT key combination can be mapped


"=============================== a-z ===================================
" USER INTERFACE "
"=======================================================================
colorscheme wombat256
set background=dark " Assume a dark background
set completeopt=longest,menuone
set cmdheight=1 " Number of screen lines to use for the command-line
set cursorcolumn " Highlight the current column
set cursorline " Highlight current line
set number " Turn on line numbers
set incsearch " Highlight as we type our search phrase
set laststatus=2 " Always show the status line
set lazyredraw " Do not redraw while running macros
set linespace=0 " Don't insert any extra pixel lines betweens characters
set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$
 " Display unprintable characters when we hit :set list
set matchtime=5 " How many tenths of a second to blink matching brackets for
set nohlsearch " Do not highlight searched for phrases
set nostartofline " Leave my cursor where it was
set novisualbell " Don't blink for error messages
set report=0 " Message will be given for most ":" commands
set ruler " Always show current positions along the bottom
set scrolloff=5 " Keep 5 lines (top/bottom) for scope
set sessionoptions=resize,winpos,winsize,buffers,tabpages,folds,curdir,help
set shortmess=aOstT " Shortens messages to avoid all the hit-enter prompts
set showcmd " Show the command being typed
set showmatch " Show matching brackets
set showmode " Display the current mode
set t_Co=256 " ViM can use 256 colors inside Gnome Terminal
set statusline=%1*%m%*%r%h%w%f\[%n]\ [mode:%{&ff}]\ [filetype:%Y]\ %{'['.(&fenc!=''?&fenc:&enc).']'}\ [line:%l/%L]\ [col:%v]\ [%p%%]
    hi User1 term=inverse,bold cterm=inverse,bold ctermfg=red " highlight modified flag in red
set viewoptions=folds,options,cursor,unix,slash
 " Changes the effect of the :mkview commands, better unix / windows compatibility.
syntax on " Syntax highlighting on


"=============================== a-z ===================================
" TEXT FORMATTING "
"=======================================================================
set expandtab " No real tabs please!
set formatoptions=tcrqn " How automatic formatting is to be done
"    |||||
"    ||||+- Recon numbered lists
"    |||+-- gq formats comments (?)
"    ||+--- Insert comment leader (?)) on <CR>
"    |+---- Autowrap COMMENTS using textwidth
"    +----- Autowrap TEXT using textwidth 
set ignorecase " Case insensitive by default
set infercase " Case inferred by default
set nowrap " Do not wrap line
set shiftround " When at 3 spaces, and I hit > ... go to 4, not 5
set shiftwidth=4 " Auto-indent amount when using cindent
set smartcase " If there are caps, go case-sensitive
set softtabstop=4 " When hitting tab or backspace, how many spaces 
                  "should a tab be
set tabstop=8 " Real tabs should be 8, and they will show with set list on
              " session settings  
set textwidth=80 " line length above which to break a line
set wrapmargin=4 " Margin from the right in which to break a line

" reading Ms-Word documents, requires antiword
autocmd BufReadPre *.doc set ro 
autocmd BufReadPre *.doc set hlsearch! 
autocmd BufReadPost *.doc %!antiword "%" 

"=============================== a-z ===================================
" FOLDING "
"=======================================================================
set foldenable " Turn on folding
set foldlevel=50 " Don't autofold anything
set foldmarker={,} " Fold C style code (only use this as default
                   " if you use a high foldlevel)
set foldmethod=manual " Fold manually
set foldopen=block,hor,mark,percent,quickfix,tag " What movements open folds


"=============================== a-z ===================================
" COMPLETION "
"=======================================================================
autocmd FileType c set omnifunc=ccomplete#Complete
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType java setlocal completefunc=javacomplete#Complete
autocmd FileType java setlocal omnifunc=javacomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
set complete=.,w,b,u,t,i " Automatically complete any class, method, or field name
setlocal omnifunc=syntaxcomplete#Complete


"=============================== a-z ===================================
" JAVA "
"=======================================================================
autocmd FileType java runtime! autoload/javacomplete.vim
let java_allow_cpp_keywords=1
let java_comment_strings=1
let java_highlight_all=1
let java_highlight_debug=1
let java_highlight_functions="style"
let java_highlight_java_lang_ids=1
let java_ignore_javadoc=1
let java_mark_braces_in_parens_as_errors=1
    "-------------------------------"
    " COMPILE - FIX ERRORS AND RUN  "
    "-------------------------------"
    autocmd Filetype java set makeprg=javac\ %
    set errorformat=%A%f:%l:\ %m,%-Z%p^,%-C%.%#
    map <F5> :w<CR>:make<CR>:copen<CR>
    map <F6> :cprevious<CR>
    map <F7> :cnext<CR>
    map <F8> :call RunClass()<CR>
        func! RunClass()
                :!java -cp "%:p:h" "%:t:r"
        endfunc

"=============================== a-z ===================================
" MAPPING "
"=======================================================================
let mapleader = ","
nnoremap ; :
nmap <C-a> ggVG                 " Select all
nmap <C-n> :tabnew<CR>          " Open a new tab
imap <C-s> :w<CR>               " Control-s be 'save' as it is in most other editors
map bn :bn<CR>                  " Move to next buffer
map bp :bp<CR>                  " Move to previous buffer
map bd :bd<CR>                  " Delete current buffer
map qq :close<CR>               " Close VIM 
map QQ :q!<CR>                  " Force quit VIM
map FF zf9j                     " Fold 10 lines down
map J <C-f>                     " Page down
map K <C-b>                     " Page up
map S :w<CR>                    " Save
map Q :q<CR>                    " Quit
"--------------------"
" Interact with UNIX "
"--------------------"
map ,e :e ~/.vimrc<CR>          " Open vimrc for modify settings
map <F2> :so $HOME/.vimrc<CR>   " Reload .vimrc
map <F3> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR> " Rebuild ctags database
map <F4> :shell<CR>             " Execute a shell
map ,cd :lcd %:p:h<CR>         " cd to current file directory
    "-----------------------------------"
    " Copy-Paste & Paragraph Formatting "
    "-----------------------------------"
    vmap ,c "+y                     " Copy to other text editors
    vmap ,x "+x                     " Cut to other text editors
    cmap ,v "+gP
    nmap ,v "+gP
    imap ,v <Esc>"+gPa
    map ,lc :%s/\<./\l&/g<CR>       " 1st letter of each word lowercase
    map ,uc :%s/\<./\u&/g<CR>       " 1st letter of each word uppercase
    map ,lf :%s/.*/\l&<CR>          " 1st letter of each line lowercase
    map ,uf :%s/.*/\u&<CR>          " 1st letter of each line uppercase
" ---------------"
" Plugin Mapping "
" ---------------"
nmap nt :NERDTreeToggle<CR>         " Toggle nerd tree file explorer
nmap tt :TagbarToggle<CR>               " Tagbar source code browser
nmap TT :TlistToggle<CR>                " View Taglist, source code browser
nmap <silent> <leader>c :Calendar<CR>   " Open the calendar
nmap <silent> <Leader>t :CommandT<CR>
nmap <silent> <Leader>b :CommandTBuffer<CR>
nmap <silent> <Leader>f :CommandTFlush<CR>
    "-----------------------------"
    " Moving Through Split Window "
    "-----------------------------" 
    map <M-Down> <Esc><C-w>j
    map <M-Up> <Esc><C-w>k
    map <M-Right> <Esc><C-w>l
    map <M-Left> <Esc><C-w>h
"------------------------ "
"  Move Split Window to:  "
"-------------------------"
map tj <C-W>J
map tk <C-W>K
map th <C-W>H
map tl <C-W>L
    "--------------------"
    " Resize Split Window"
    "--------------------"
    nmap <C-Down> <C-W>-<C-W>-
    nmap <C-Up> <C-W>+<C-W>+
    nmap <C-Right> <C-W>><C-W>>
    nmap <C-Left> <C-W><<C-W><


"=============================== a-z ===================================
" ABBREVIATIONS "
"=======================================================================
iab ddtt <C-R>=strftime("%d %b %Y, %I:%M%P")<CR>
 " Insert current date & time
iab psvm public static void main (String[] args ) {
iab sop System.out.println ("


"=============================== a-z ===================================
" CONFIGURE TAGS "
"=======================================================================
autocmd FileType java set tags=/home/foss/Workspace/.tags
set tags=~/.tags


"=============================== a-z ===================================
" GUI SETTINGS "
"=======================================================================
if has("gui_running")
    "colorscheme candycode
    set columns=80
    "set guifont=Tahoma:h10
    "set guioptions-=m
    "set guioptions-=T
    set mousehide " Hide the mouse cursor when typing 
    set lines=25
endif


"=============================== a-z ===================================
" PLUG-IN MANAGEMENT "
"=======================================================================
    "-----------------"
    " == COMMAND-T == "
    "-----------------"
    let g:CommandTMaxFiles=200
    let g:CommandTMaxHeight=10
"-----------------------------"
" === AUTO-COMPLETE-POPUP === "
"-----------------------------"
let g:AutoComplPop_CompleteoptPreview=1
let g:AutoComplPop_Behavior =
\{ 'python' : [ ['\k\{0,}$', "\<C-x>\<C-o>"],
\ ['\k\{0,}$', "\<C-x>\<C-n>"]
\ ],
\ 'css' : [ ['\k\{0,}$', "\<C-x>\<C-o>"],
\ ['\k\{0,}$', "\<C-x>\<C-n>"]
\ ],
\ 'javascript' : [ ['\k\{0,}$', "\<C-x>\<C-o>"],
\ ['\k\{0,}$', "\<C-x>\<C-n>"]
\ ],
\ 'java' : [ ['\k\{0,}$', "\<C-x>\<C-n>"],
\ ['\k\{0,}$', "\<C-x>\<C-u>"]
\ ],
\ 'xml' : [ ['\k\{0,}$', "\<C-x>\<C-n>"],
\ ['\k\{0,}$', "\<C-x>\<C-o>"]
\ ],
\ 'html' : [ ['\k\{0,}$', "\<C-x>\<C-o>"],
\ ['\k\{0,}$', "\<C-x>\<C-n>"]
\ ]
\ }
    "----------------------"
    " === JAVACOMPLETE === "
    "----------------------"
    setlocal completefunc=javacomplete#CompleteParamsInfo
    setlocal omnifunc=javacomplete#Complete
    inoremap <buffer> <C-X><C-U> <C-X><C-U><C-P>
    inoremap <buffer> <C-S-Space> <C-X><C-U><C-P> 
        if has("autocmd")
            autocmd Filetype java setlocal omnifunc=javacomplete#Complete
            autocmd Filetype java setlocal 
        endif
"-------------------"
" === SUPER-TAB === "
"-------------------"
let g:SuperTabContextDefaultCompletionType = "<c-x><c-o>"
let g:SuperTabDefaultCompletionType = "context"
    "--------------"
    " == TAGBAR == "
    "--------------"
    let g:tagbar_userarrows = 1
    let g:tagbar_width = 25
"-----------------"
" === TAGLIST === "
"-----------------"
let Tlist_Enable_Fold_Column = 1 " Do show folding tree
let Tlist_Show_One_File = 1 "Show tags for the current buffer only
let Tlist_Exit_OnlyWindow = 1 " If you are the last, exit ViM
let Tlist_File_Fold_Auto_Close = 0 " Fold closed other trees
let Tlist_Sort_Type = "name" " Order by name
let Tlist_WinWidth = 25 " 25 columns wide

set secure " The Vim documentation suggests adding this as the last line of our vimrc

"-------------------------- vimrc end here -----------------------------

"=============================== a-z ===================================
" PLUGIN LIST "
"=======================================================================
" Ant_menu              : http://www.vim.org/scripts/script.php?script_id=155
" AutoCompletePop       : http://vim.sourceforge.net/scripts/script.php?script_id=1879
" BufferExplorer        : http://www.vim.org/scripts/script.php?script_id=42
" Calendar              : http://vim.sourceforge.net/scripts/script.php?script_id=52
" ColorSamplePack       : http://www.vim.org/scripts/script.php?script_id=625
" Command-T             : https://wincent.com/products/command-t  
" CSApprox              : http://www.vim.org/scripts/script.php?script_id=2390
" Fugitive              : http://www.vim.org/scripts/script.php?script_id=2975
" JavaComplete          : http://vim.sourceforge.net/scripts/script.php?script_id=1785
" L9                    : http://www.vim.org/scripts/script.php?script_id=3252
" NERDTree              : http://www.vim.org/scripts/script.php?script_id=1658
" OmniCppComplete       : http://www.vim.org/scripts/script.php?script_id=1520
" Pathogen              : http://www.vim.org/scripts/script.php?script_id=2332 
" Solarized             : http://www.vim.org/scripts/script.php?script_id=3520
" SuperTab              : http://www.vim.org/scripts/script.php?script_id=1643
" Tagbar                : http://www.vim.org/scripts/script.php?script_id=3465
" Taglist               : http://www.vim.org/scripts/script.php?script_id=273
" UpAndDown             : http://www.vim.org/scripts/script.php?script_id=2586

August 05, 2011

VIM: Mengganti tombol ESC dengan CAPSLOCK

Saat bekerja/bermain dengan VIM, tombol ESC termasuk yang paling sering di gunakan, tapi termasuk "susah" di jangkau dari tombol home = asdf jkl;. Saya kemudian berniat mengganti tombol dengan ESC dengan CAPSLOCK.

Setelah browsing, saya belum nemu cara yang sederhana. Harus ngetik beberapa kata di konsole, contohnya disini.

Ternyata ada cara yang lebih sederhana dengan menukar tombol dan secara permanen.Berikut screenshot dari Debian Squeeze yang saya pakai.

System > Preferences > Keyboard > CapsLock Key Behaviour

 keyboard preferences


Dengan CAPSLOCK yang lebih mudah di jangkau, kita bisa lebih cepat beralih dari insert mode ke command mode. Happy Vimming :)

June 24, 2011

Message in the Pocket

Boy: Baby, we need to talk.
Girl: Ricardo, what do u mean?
Boy: Something has come up...
Girl: What? What's wrong? Is it bad?
Boy: I don't want to hurt you, baby.
Girl: *Thinks* Oh my God, I hope he doesnt break up with me... I love him so much.
Boy: Baby, are you there??
Girl: Yeah, I'm here. What is so important??
Boy: I'm not sure if I should say it..
Girl: Well, you already brought it up, so please just tell me.
Boy: I'm leaving...
Girl: Baby, what are u talking about?? I don't want you to leave me, I love you.
Boy: Not like that, I mean I'm moving far away.
Girl: Why? All of your famliy lives over here.
Boy: Well, my father is sending me away to a boarding school far away.
Girl: I can't believe this.

[FATHER: (Picks up the other phone, interrupts & yells furiously
ERICA!, what did I tell you about talking to boys?!!!... Get off the damn phone!! (And hangs up).]
Boy: Wow, your father sounds really mad.
Girl: You know how he gets, but anyways, I dont want you to go.
Boy: Would you run away with me?
Girl: Baby, you know I would, I would do anything for you, but I can't... You don't know what would happen if I did. My dad would kill me!
Boy: *Sad* It's okay.. I understand, I guess..
Girl: *Thinking* I can't believe what's going on.
Boy: I need to give you something tonite, because I am leaving on flight 1-80 in the morning, so I need to see you now.
Girl: Okay, I will sneak out & meet you at the park.
Boy: Okay, I'll meet you there in 20 minutes.

[They meet at a nearby park, they both hug eachother. And he gives
her a note.]

Boy: Here you go, this is for you. I gotta go.
Girl: *Tear* (Begins to cry.)
Boy: Baby, dont cry, you know I love you... But I have to go.
Girl: Okay (Begins to walk away.)

[They both go back home. And Erica begins to read the letter he gave her]
It says...

"Erica,
You probably already know that I'm leaving, I knew this would be better if I wrote a letter explaining the truth about how much I care about you. The truth is, is that I never loved you, I hated you so much, you are my bitch and don't you ever forget that. I never cared about you, and never wanted to talk to you, and be around you. You really have no clue how much I hate you. Now that I'm leaving I thought you should know that I hate you, bitch. You never did the right thing, and you were never there. I didnt think I could hate someone as much as I hate you. And I never want to see you, for the rest of my life, I will never miss kissing you like before, I never want to cuddle up, how we used to. I will not miss you and that's a promise. You never had my love, and I want you to remember that. Bitch, you keep this letter because this may be the last thing you have from me. Fuck, I hate you so much. I will not talk to you soon bitch... Goodbye.
- Ricardo"



[ Erica begins to cry, she throws the paper in tha garbage & crys for hours ]
... A day passes, she is sad, depressed and she feels so lonely... Then she gets a phone call....

Friend: How are you feeling?
Girl: I just cant believe this happened.. I thought he loved me.
Friend: Oh, about that. Ricardo left me a message. A few days ago. He told me to tell you to look in your jacket pocket or something...

Girl: Umm.. okay.

She finds a piece of paper in the jacket, It says:
"Baby I hope you find this before you read my letter. I knew your dad might read it, so I switched a few words...

Hate = Love
Never = Always
Bitch = Baby
Will not= will

.... I hope you didn't take that seriously because I love you with all my heart, and it was so hard to let you go that's why I wanted you to run away with me... -Ricardo"

Girl: Oh my God! It's a letter.. Ricardo does love me!!, he must of slipped it into my pocket when he hugged me. I can't believe how stupid I am!!

Friend: lol Okay but I g2g... Call me later.
Girl: *happy* okay, bye, I'll be at home waiting for my baby to call me!

... Erica turns the T.V. on......

[Breaking news] "An airplane has crashed. Over 47 young boys died, we are still searching for survivors... This is a tragedy we will never forget, this plane was flight 1-80... it was on its way to an all boys boarding school..." the Reporter says.

[ She turns off the t.v. ... 3 days later, she kills herself, because of the fact that Ricardo was dead & she had nothing to live for... ]

... A day after that the phone rings. Nobody answers. It was Ricardo, he called to leave a message.

"Its Ricardo, I guess you're not home so, I called to let you know that I'm alive, I missed my flight because I had to see you one last time. So, I hope your not worried. I am staying for good"