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 :)