VIM / GVIM

Binary Editing

View hexadecimal and ASCII
:%!xxd
View plain hexadecimal
:%!xxd -p
Revert hexadecimal to binary
:%!xxd [-p] -r
View bits (not reversible)
:%!xxd -b

Blockwise Visual Mode

Start
Ctrl-V (windows Ctrl-Q)
Move
j, k, …
Insert text: I text Esc
: Insert register
I Ctrl-R register Esc
Append text: $ A text Esc
: Append register
$ A Ctrl-R register Esc

Convert

Encoding
:e ++enc={fencoding} [file]
File Format
:e ++ff={format} [file]

encoding: utf-8, latin-1, …
format: unix, dos

Example:

:e ++enc=latin-1
:e ++ff=dos test.bat

Folds

Persistent folds between sessions [1]
add following to vimrc
if has("autocmd")
  augroup AutoSaveFolds
    autocmd!
    autocmd BufWinLeave *.* mkview
    autocmd BufWinEnter *.* silent loadview
  augroup END
endif

Scripts

Show all loaded scripts [2]
:scriptnames

Settings

Find where an option was set [2]
:verbose [option]
:verbose set et?
:verbose autocmd BufEnter
Modeline
Settings for actual file.
[text] {white} vim: [white] {option} [{white|:} {option}]...
[text] {white} vim: [white] se[t] {option} [{white} {option}]... : [text]

Example:
/* vim:autoindent:shiftwidth=4: */
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.