New FAMILUG

The PyMiers

Tuesday 21 July 2015

[Vim] TOhtml, filetype, plugin, indent

1. TOhtml

Trong Vim, ở normal mode, gõ ``:TOhtml``, vim sẽ convert file hiện tại thành code HTML.

2. filetype
Vim có cơ chế load plugin dựa trên kiểu của file đang mở.
Để xem thiết lập hiện tại, gõ ``:filetype``
Kết quả có thể trông như thế này:
filetype detection:ON  plugin:ON  indent:ON
Gõ ``:filetype on`` để bật chế độ tự động nhận dạng filetype. Gõ ``:filetype off`` để tắt.

3. plugin

Plugin chia làm 2 loại:
- global plugin: thường nằm ở thư mục $VIMRUNTIME/macros
- filetype plugin: thường nằm ở thư mục $VIMRUNTIME/ftplugin

filetype plugin là plugin dành cho 1 loại file nào đó, ví dụ HTML hay Python.
Để xem filetype của file hiện tại, gõ: ``:set filetype``
Để load filetype plugin cho loại file hiện tại, gõ ``:filetype plugin on``

4. indent
Mỗi loại file (filetype) cần một kiểu indent riêng (thò ra thụt vào).
Để load indent file cho loại file hiện tại, gõ ``:filetype indent on``

Để bật hết lên, gõ ``:filetype plugin indent on``
Và dòng này thường xuất hiện ở các file vimrc.

Đọc thêm ở ``:help :filetype-overview``

No comments:

Post a Comment