SENOO, Ken
|
||||||||||||
There Are 2 Trends for Development Style
|
Updating(最新化)Using latest technology (tools, API, library, device) ↓ Achieving high performance & function Example
|
Keeping(維持)Using de jure standard or common technology (ISO, IEEE, W3C, standard library, etc.) ↓ Achieving high compatibility & durability Example
|
|
|
Also Vim has same trends.
|
|
Importance of Keeping
|
| POSIX( |
|---|
|
| POSIXism (POSIX fundamentalism:POSIX原理主義) |
|---|
|
| Good |
|---|
|
| Bad |
|---|
|
|
| Shell script with conforming to POSIX | Web app with conforming to W3C |
|---|---|
| Parsrs https://github.com/ShellShoccar-jpn/Parsrs |
Metropiper http://lab-sakura.richlab.org/METROPIPER/HTML/MAIN.HTML |
|
|
| ShellShoccar-jpn/Parsrs: CSV, JSON, XML text parsers and generators written in pure POSIX shellscript | "Metropiper" for train aproaching information web app.(接近情報表示プログラム「メトロパイパー」) |
|
|
| Paper | HP |
|---|---|
|
|
| Peer reviewed paper on Information Processing Society of Japan 2017-10-15 https://www.ipsj.or.jp/dp/contents/publication/32/S0804-R1601.html |
posixism.org http://posixism.org/ |
| |
Vim and POSIXism
Applying POSIXism to Vim |
ed
↓
ex
↓
vi
↓
vim
| Initial release | Name | Creator (Nick name) |
Portrait | Bio |
|---|---|---|---|---|
| 1969-08 | ed | Kenneth Lane Thompson (Ken Thompson) |
![]() (Wikimedia Commons) |
|
| 1976-09 1979-05 |
ex vi |
William Nelson Joy (Bill Joy) |
![]() (Wikimedia Commons) |
|
| 1988 | vim |
Bram Moolenaar |
![]() (Wikimedia Commons) (http://www.zimbu.org/) |
|
Vi = Visual Interface or Visual Editor
| Date | Editor | Description |
|---|---|---|
| 1969-08 | ed | Initial release for line editor ed as a part of UNIX by Kenneth Lane Thompson. |
| 1976-02 | em | George Coulouris enhanced ed to make em (editor for mortals). |
| 1976-09 | ex 0.1 | Bill Joy took code from em to make en, and then "extended" en to create ex 0.1. |
| 1977-10 | ex 1.1 | adding a full-screen visual mode to ex. |
| 1979-05 | ex (vi) 2.0 | vi as a hard link to ex. |
| 1979-06-10 | vi 2.7 | last version for Joy as a leading developer |
| 1979-11-01 | vi 3.1 | shipped with 3BSD |
| 1980-08-20 | vi 3.5 | last version from Joy contribution |
| 1981-10-16 | vi 3.7 | UNIX System V adopting vi. And distributed Solaris, HP-UX, Tru64 UNIX, AIX. |
| 1987-06 | STEVIE | STEVIE (ST Editor for VI Enthusiasts), a limited vi clone. |
| 1988 | Vim | Vi IMitation on the Amiga |
| 1990-01 | Elvis | Steve Kirkendall posted a new clone of vi, Elvis. |
| 1994 | nvi | Created nvi from Elvis 1.8 for 4.4 BSD Lite. |
vi - Wikipedia
Birth of Vim
|
| Date | Version | Description |
|---|---|---|
| 1988 | 1.0 | Vi IMitation on the Amiga (same as first POSIX release year) |
| 1991-12-14 | 1.14 | First public release |
| 1992 | 1.22 | Port to Unix and MS-DOS |
| 1993-12-21 | 2.0 | Renamed to Vi IMproved, horizontal scroll and 'wrap', wildcard expansion, |
| 1994-08-16 | 3.0 | Multiple buffers and windows |
| 1996-05-21 | 4.0 | GUI, autocmd, mouse, swap file, Windows NT & 95, OS/2, tag, viminfo |
| 1998-02-19 | 5.0 | Syntax highlighting, Vim script, perl and python, Win32 GUI, VMS, BeOS, Mac GUI, |
| 2001-09-27 | 6.0 | Folding, plugins, vertical split, diff, UTF-8, multi-language, netrw, quickfix |
| 2002-03-24 | 6.1 | Bug-fix release |
| 2003-06-01 | 6.2 | GTK2, arabic text, :try |
| 2004-06-08 | 6.3 | Bug-fix release |
| 2005-10-15 | 6.4 | Bug-fix release |
| 2006-05-08 | 7.0 | Vim script feature(list, dictionary, funcref, +=, -=, .=, vimball), spell checking, Omni completion, tab pages, vimgrep, location list |
| 2007-05-12 | 7.1 | Bug-fix release |
| 2008-08-09 | 7.2 | Floating points support. |
| 2010-08-15 | 7.3 | Persistent undo, encryption, conceal, lua, python3 |
| 2013-08-10 | 7.4 | New regexp engine, better python interface |
| 2016-09-12 | 8.0 | Asynchronous I/O support, channels, jobs, timers, lambda and closure, packages etc. |
Ref: Talk of TAKATA@VimConf 2016 Introduction to Vim 8.0
Which Vim Version Is It Possible?
Example
Which version is it possible for .vimrc or plugin? |
Concept for Default Vim VersionTime is going now. We need to fix the base date for default Vim version.
Research the oldest Vim version |
CentOS 5 looks like the oldest supported OS.
| Type | OS | Release | End of life | vi/Vim version |
|---|---|---|---|---|
| POSIX 2016 | 2016-09-30 | |||
| Linux | CentOS 5.0&5.11 | 2007-04-12 | 2017-03-31 | 7.0 |
| Linux | Debian 7.0 | 2013-05-03 | 2018-05-31 | 7.3 |
| Linux | Ubuntu 12.04 | 2012-04-26 | 2017-04-28 | 7.3 |
| Linux | OpenSUSE | 2013-11-19 | 2016-02-03 | 7.4 |
| BSD | FreeBSD 9.0 | 2012-01-10 | 2016-12-31 | None |
| UNIX | Mac OS X 10.6 (Snow Leopard) | 2009-08-28 | 2014-02-25 | 7.2 |
| UNIX | HP-UX 11.31 | 2007-02-15 | 2020-12-31 | None |
| UNIX | Solaris 10.3 | 2005-01-31 | 2021-01-31 | None |
| UNIX | Solaris 11.3 | 2011-11-09 | 2034-11-30 | 7.3 |
Interface is important for extension Vim function.
| Date | Version | Interface |
|---|---|---|
| 1998-02-19 | 5.0 | perl, python |
| 1998-08-24 | 5.2 | tcl, cscope |
| 1999-07-26 | 5.4 | OLE |
| 2001-09-27 | 6.0 | ruby |
| 2001-09-27 | 6.0 | deubgger, workshop, sign |
| 2003-06-01 | 6.2 | Netbeans |
| 2006-05-08 | 7.0 | MzScheme |
| 2010-08-15 | 7.3 | lua, python3 |
:help standard-pugin-list or $VIMRUNTIME/plugin/README.txt
| Version | Name | Description |
|---|---|---|
| 7.0 | getscriptPlugin.vim | Downloading latest version of Vim scripts |
| 6.0 | gzip.vim | Reading and writing compressed files |
| 6.0 | netrw.vim (explorer.vim) | Reading and writing files over a network/directory |
| 6.0 | rrhelper.vim | used for --remote-wait editing |
| 6.2 | tohtml.vim | convert a file with syntax highlighting to HTML |
| 7.0 | matchparen.vim | Highlight matching parens |
| 7.0 | spellfile.vim | download a spellfile when it's missing |
| 7.0 | tarPlugin.vim | Tar file explorer |
| 7.0 | vimballPlugin.vim | Create a self-installing Vim script |
| 7.0 | zipPlugin.vim | Zip archive explorer |
| 8.0 | logipat.vim | Logical operators on patterns |
Ref: Talk of Linda_pp@VimConf2013, Do You Know about Vim Runtime Files? // Speaker Dec
$VIMRUNTIME/macros/README.txt
| Bundled Version | Name | Description |
|---|---|---|
| 5.0 or older | hanoi | Macros that solve the tower of hanoi problem. |
| 5.0 or older | life | Macros that run Conway's game of life. |
| 5.0 or older | maze | Macros that solve a maze (amazing!). |
| 5.0 or older | urm | Macros that simulate a simple computer: "Universal Register Machine" |
| 6.0 or older | less.vim, sh, bat | make Vim work like less (or more) |
| 5.0 or older | dvorak | Dvorak keyboard support; adds mappings |
| 7.0 | editexisting | when editing a file that is already edited with " another Vim instance, go to that Vim instance |
| 6.0 or older | justify | justifying text. |
| 6.0 or older | matchit | makes the % command work better |
| 5.0 or older | shellmenu | menus for editing shell scripts in the GUI version. |
| 5.0 or older | swapmouse | swap left and right mouse buttons |
Since Vim 8.0, dvorak, editexisting, justify, matchit, shellmenu, swapmouse is moved $VIMRUTNIME/pack.
Macro is existing since old Vim release.
Macros is not enabled on default. If you want to use macro, try like following commands.
:source $VIMRUNTIME/<macro-name>.vim
:runtime macros/<macro-name>vim
Ref: talk of Linda_pp@VimConf2013, Do You Know about Vim Runtime Files? // Speaker Dec
Bundled CommandsVim has 2 types of bundled commands.
Bundled commands is useful for less command OS (Windows). |
:help starting
| Alias | Option | Description |
|---|---|---|
| ex | vim -e | Start in Ex mode (see |Ex-mode|). |
| exim | vim -E | Start in improved Ex mode (see |Ex-mode|). |
| view | vim -R | Start in read-only mode (see |-R|). |
| gvim | vim -g | Start the GUI (see |gui|). |
| gex | vim -eg | Start the GUI in Ex mode. |
| gview | vim -Rg | Start the GUI in read-only mode. |
| rvim | vim -Z | Like "vim", but in restricted mode (see |-Z|). |
| rview | vim -RZ | Like "view", but in restricted mode. |
| rgvim | vim -gZ | Like "gvim", but in restricted mode. |
| rgview | vim -Rgz | Like "gview", but in restricted mode. |
| evim | vim -y | Easy Vim: set 'insertmode' (see |-y|). |
| eview | vim -yR | Like "evim" in read-only mode. |
| vimdiff | vim -d | Start in diff mode |diff-mode|. |
| gvimdiff | vim -gd | Start in diff mode |diff-mode|. |
ex, gvim, vimdiff is useful alias especially.
Official Vim archive for Windows (gvim*.exe) is here: ftp://ftp.vim.org/pub/vim/pc/
Windows Vim is installed C:\Program Files (x86)\Vim\. External commands have .exe extension.
Find external commands by following cmd.exe commands.
dir /s /b "%ProgramFiles(x86)%\Vim\*.exe"
| Command | Vim 5.0 | Vim 6.0 | Vim 7.0 | Vim 8.0(.586) | Description |
|---|---|---|---|---|---|
| install.exe | |
○ | ○ | ○ | Installer. |
| uninstal.exe | ○ | ○ | ○ | Uninstaller. | |
| uninstall-gui.exe | ○ | ○ | ○ | Uninstaller with GUI. | |
| vim.exe | ○ | ○ | CUI vim. | ||
| gvim.exe | ○ | ○ | ○ | ○ | GUI vim. |
| vimrun.exe | ○ | ○ | ○ | Vim interface for external commands on cmd.exe. | |
| ctags.exe | ○ | Creating tags (DB for code definition location). | |||
| xxd.exe | ○ | ○ | ○ | ○ | Required for binary editing. |
| diff.exe | ○ | ○ | Required for vimdiff. | ||
| tee.exe | ○ | Required for :make in progress output. |
My past research : My Future Sight for Past: Windows版Vimインストール時の付属コマンド
if <is-enabled-new-feature>
<use-new-feature-here>
endif
set <general-option>=<env1>,<env2>,<env3>
| Topic of Compatible Tips |
|---|
|
| Item | Description |
|---|---|
| v:version | Vim major & minor version (5.01 = 501). |
| has('patch-X.X.XXX') | Included patch (ex: has('patch-7.4.123')). |
v:version and has('patch-X.X.XXX')Patch 7.4.1952
Problem: Cscope interface does not support finding assignments.
Solution: Add the "a" command. (ppettina, closes #882)
Files: runtime/doc/if_cscop.txt, src/if_cscope.c
if has('cscope')
set cscopequickfix=s-,g-,d-,c-,t-,e-,f-,i-
if v:version >= 800 || has('patch-7.4.1952')
let &cscopequickfix .= ',a-'
endif
endif
has()has() is available for checking if interface, OS, GUI, compiled feature enabled
(:help featurelist).
| Item | Value |
|---|---|
| Interface | lua, mzscheme, perl, python, python3, ruby, tcl |
| GUI | gui_running, mouse |
| UNIX | unix |
| Mac | mac, macunix, osx |
| Windows | win16, win32, win64 |
| Cygwin, MSYS(2) | win32unix |
If you want to know detail about OS, use external commands by system().
| OS | Command |
|---|---|
| Linux | uname -s, cat /etc/os-release, lsb_release -a |
| Windows | VER |
has()""" Platform
let s:IS_WINDOWS = has('win64') || has('win32') || has('win16')
let s:IS_CYGWIN = has('win32unix')
let s:IS_MAC = has('mac') || has('macunix') || has('gui_macvim')
let s:IS_LINUX = has('unix') && !s:IS_MAC && !s:IS_CYGWIN
let s:IS_WINDOWS_7 = s:IS_WINDOWS && system('VER') =~# 'Version 6.1'
"" mouse
if has('mouse')
set mouse=a
set ttymouse=xterm2
endif
exists()exists() is available for checking if variable, option, function, event enabled.
| Item | Description |
|---|---|
| &option-name | Vim option (only checks if it exits). |
| +option-name | Vim option that works. |
| $ENVNAME | environment variable. |
| *funcname | built-in function or user defined function. |
| varname | internal variable. |
| :cmdname | Ex command: built-in command, user command. |
| :2match | The :2match command. |
| :3match | The :3match command. |
| #event | autocommand defined for this event. |
| #event#pattern | autocommand defined for this event and pattern.. |
| #group | autocommand group exists. |
| #group#event | autocommand defined for this group and event. |
| #group#event#pattern | autocommand defined for this group, event and pattern. |
| ##event | autocommand for this event is supported. |
+option-name, *funcname, :cmdname, ##event is often used.
exists()In .vimrc, exists('+option-name') is enough for option compatibility.
New option needs to check by exists().
if exists('+packpath')
set packpath+=~/.vim
endif
if exists('##CmdlineEnter')
autocmd CmdlineEnter * pwd
endifRelease v8.0.1206: patch 8.0.1206: no autocmd for entering or leaving the command line · vim/vim
If we want to use external exe or file, check it enabled.
| Item | Description |
|---|---|
| executable({expr}) | checks if an executable with the name {expr} exists. |
| exepath({expr}) | return the full path for executable. |
| filereadable({file}) | TRUE when a file with the name {file} exists, and can be read. |
| filewritable({file}) | The result is a Number, which is 1 when a file with the name {file} exists, and can be written. |
| finddir({name}[, {path}[, {count}]]) | Find directory {name} in {path}. |
| findfile({name}[, {path}[, {count}]]) | Just like finddir(), but find a file instead of a directory. |
| shellescape({string} [, {special}]) | Escape {string} for use as a shell command argument. |
| system({expr} [, {input}]) | Get the output of the shell command {expr} as a string. |
| systemlist({expr} [, {input}]) | Same as system(), but returns a List with lines (parts of output separated by NL) with NULs transformed into Nls. |
executable, filereadable, shellescape, system is often used.
## For :grep
if executable('ag')
set grepprg=ag\ --vimgrep\ $*
set grepformat=%f:%l:%c:%m
endif
"" Add executable permission for shebang files
autocmd BufWritePost * :call s:Add_execmod()
function! s:Add_execmod()
let s:line = getline(1)
if strpart(s:line, 0, 2) == '#!'
let s:IS_WINDOWS = has('win64') || has('win32') || has('win16')
if s:IS_WINDOWS
call system('icacls ' . shellescape(expand('%') . ' /grant ' . $USERNAME . ':(X)'))
else
call system('chmod +x -- ' . shellescape(expand('%')))
endif
endif
endfunction
Encodings
I'll talk about encoding here to end. |
help: mbyte-encoding
| Option | Description |
|---|---|
| Encoding options | |
| encoding | Sets the character encoding used inside Vim (viminfo etc.). |
| termencoding | Encoding used for the terminal. |
| :scriptencoding | Specify the character encoding used in the script. |
| fileencoding | Sets the character encoding for the file of this buffer. |
| fileencodings | This is a list of character encodings considered when starting to edit an existing file. |
| Other text options | |
| ambiwidth | Tells Vim what to do with characters with East Asian Width Class Ambiguous. |
| bomb | When writing a file and fileencoding is a unicode variants, a BOM (Byte Order Mark) is prepended to the file. |
| endofline | When writing a file and this option is off and the 'binary' option is on, or 'fixeol' option is off, no <EOL> will be written for the last line in the file. |
| fixendofline | When writing a file and this option is on, <EOL> at the end of file will be restored if missing. |
| fileformat | This gives the <EOL> of the current buffer, which is used for reading/writing the buffer from/to a file. dos: <CR> <NL>, unix: <NL>, mac <CR>. |
| fileformats | This gives the end-of-line (<EOL>) formats that will be tried when starting to edit a new buffer and when reading a file into an existing buffer. |
Basic Concept for Character Encoding(Coded) character set (ex. Unicode) ↓↑ Character encoding (IANA) (ex. UTF-8) ↓↑ Byte (bit) |
| Character set | ASCII | Unicode | Unicode | JIS X 0201 JIS X 0208 |
JIS X 0208 + α |
ASCII JIS X 0201 JIS X 0208 JIS X 0212 |
ASCII JIS X 0201 JIS X 0208 |
|---|---|---|---|---|---|---|---|
| Character | A | あ | あ | あ | あ | あ | あ |
| ↓↑ | ↓↑ | ↓↑ | ↓↑ | ↓↑ | ↓↑ | ↓↑ | |
| Character encoding |
US-ASCII, UTF-8, EUC-JP, Shift_JIS, ISO-2022-JP |
UTF-8 | UTF-16LE | Shift_JIS | Windows-31J (CP932) |
EUC-JP | ISO-2022-JP |
| ↓↑ | ↓↑ | ↓↑ | ↓↑ | ↓↑ | ↓↑ | ↓↑ | |
| Byte (hex) | 41 | e3 81 82 | 42 30 | 82 a0 | 82 a0 | a4 a2 | 1b 24 42 24 22 |
| Character set | Including set | Bit | Byte | Amount | Description | Example |
|---|---|---|---|---|---|---|
| For English | ||||||
| ASCII (ISO/IEC 646) | 7 | 1 | 128 | number, alphabet, sign. | 123abcABC+-*/ | |
| Latin-1 (ISO/IEC 8859-1) | ASCII + α | 8 | 1 | 256 | ASCII + umlaut, accent,sign for EU. | £, À |
| For universe | ||||||
| Unicode (ISO/IEC 10646, UCS) | 32 | 4 | 1114112 | One set for all of the world character. | ||
| For Japanese | ||||||
| JIS X 0201 | ASCII modified + 1 byte Katakana | 8 | 1 | 256 | Initial Japanese set with modifying ASCII \→¥, ~→ ̄. | ア, ¥,  ̄ |
| JIS X 0208 | JIS X 0211 | 8 | 2 | 6879 | Basic Japanese set. including Kanji. | あ |
| JIS X 0211 | Latin-1 subset | 8 | 2 | 61 | Control sequence. | |
| JIS X 0212 | 8 | 2 | 6067 | Additional Kanji. |
| Character encoding | Character set | Bit for encoding | Byte per char | ASCII compatible | BOM | Feature | Example |
|---|---|---|---|---|---|---|---|
| For English | |||||||
| US-ASCII | ASCII | 7 | 1 | ○ | General PC character. | ||
| ISO-8859-1 (latin1) | ISO/IEC 8859-1 | 8 | 1 | ○ | US-ASCII extended. | General English document. | |
| For universe | |||||||
| UTF-8 | Unicode | 8 | 2-6 | ○ | ○ | ASCII compatible and supporting almost character. | General PC character. |
| UTF-16 (UCS-2) | Unicode | 16 | 2, 4 | × |
○ | UTF-16 is including UCS-2. For internal encoding. | Windows registry. Java, Javascript internal. |
| UTF-32 (UCS-4) | Unicode | 32 | 4 | × | ○ | Fixed byte. For internal encoding. | |
| For Japanese | |||||||
| ISO-2022-JP | ASCII, JIS X 0201, JIS X 0208 | 7 | 1-2 | ○ | Switch character set by escape sequence. | E-mail. | |
| EUC-JP | ASCII, JIS X 0201, JIS X 0208 JIS X 0212 | 8 | 1-2 | ○ | Switch a character by shift character. | Old UNIX like OS. | |
| Shift_JIS | JIS X 0201, JIS X 0208 | 8 | 1-2 | ○ | Historical Japanese default encoding. | Historical Japanese document. | |
| Windows-31J (CP932, MS932) | JIS X 0208 + α (ex. ①, ㎞, ㎝) | 8 | 1-2 | ○ | Microsoft customized Shift_JIS (Windows default Japanese set). | Japanese Windows default. |
Multi byte encoding is depends on architecture (Big-endian, Little-endian).
| Original Byte | Big-Endian | Little-Endian |
|---|---|---|
| 12 34 | 12 34 | 34 12 |
UTF-16 and UTF-32 is encoding a character from multi bytes.
For detecting endian, append mark (BOM) to start of the file.
| UTF-16 | UTF-32 | |
|---|---|---|
| BOM for Big Endian | FE FF | 00 00 FE FF |
| BOM for Little Endian | FF FE | FF FE 00 00 |
No BOM means Big-endian.
UTF-8 is not depends on order of byte. UTF-8 BOM is only mark for easy detecting (no meaning order).
|
|---|
In Vim, set bomb and set nobomb are available for appending/removing BOM only Unicode encoding.
Vim supports many encoding. You can check :help encoding-names or iconv -l.
Following value is vim specific encoding names.
| Value | Description |
|---|---|
| default | Default value of 'encoding', depends on environment. |
| japan | UNIX: euc-jp, Windows: cp932. |
| ucs-bom | Encoding for starting BOM (utf-8, utf-16, utf-32). |
(https://senooken.jp/public/20171104/encoding-test.zip)
encoing-test.zip is including following encoding and content.
| utf-16le.txt | utf-8.txt | cp932.txt | euc-jp.txt | iso-2022-jp.txt | cp932-xsjis.txt |
| | | | | |
If your .vimrc is compatible, you can open these files correctly.
(We can check following command for fileencodings test without .vimrc.)
" vim -u NONE --cmd "set fencs=<encs>" file.txt
vim -u NONE --cmd "set fencs=utf-8" cp932.txt
fileencodings for Japanesefileencodings is list for fileencoding (text file encoding).fileencodings item until success.fileencodings is important.| Priority | Relation | Example of NG | |
|---|---|---|---|
| 1 | ucs-bom >> other | ||
| 2 | iso-2022-jp > utf-8, euc-jp, cp932 | vim -u NONE --cmd "set fencs=utf-8,iso-2022-jp" iso-2022-jp.txt | |
| 3 | euc-jp > cp932 | vim -u NONE --cmd "set fencs=cp932,euc-jp" euc-jp.txt | |
| 4 | utf-8 > cp932 | vim -u NONE --cmd "set fencs=cp932,utf-8" utf-8.txt |
"" Example of fileencodings for all clear encoding-test.zip
set fileencodings=ucs-bom,iso-2022-jp,utf-8,euc-jp,cp932This setting is not perfect. If we try opening UTF-16 without BOM, encoding is failed. But almost good.
"" Fix 'fileencoding' to use 'encoding' if the buffer only ASCII characters.
autocmd BufReadPost *
\ if &modifiable && !search('[^\x00-\x7F]', 'cnw')
\ | setlocal fileencoding=utf-8
\ | endif
fileformatsfileformat gives the <EOL> (end-of-line, line break).<CR> <NL><NL><CR>fileformats is list for fileformat.fileformats is checked automatically.fileformats is not so important as fileencodings.set fileformats=unix,dos,mac
Vim has been forcing to append line break to end of file in writing text file for a long time.
For keeping default EOL, add nofixendofline option to .vimrc in Vim 8.0 (vim 7.4.785)
"" Disabled to append LF automatically in writing
if exists('+fixendofline')
autocmd BufWritePre * setlocal nofixendofline
endifThen, set endofline and set noendofline is appending/removing EOL.
ambiwidthambiwidth option operate these appearance.'single'. For Japanese, 'double' is recommended.
set ambiwidth=double
statuslineIt is useful for text file information on statusline.
Example
"" Statusline
set laststatus=2
set statusline =[%n]%<%f " File name
set statusline+=\ %m%r%h%w " Flag for modified, readonly, help buffer, preview
set statusline+=%<%y " filetype
set statusline+=%{'['.(&fenc!=''?&fenc:&enc).':'.&ff.']'} " Encoding
set statusline+=%{&bomb?'[bomb]':''} " BOM
set statusline+=%{&eol?'':'[noeol]'} " EOL
set statusline+=[%04B] " Character code
set statusline+=%=\ %4l/%4L\|%3v\|%4P " Current position