sponsor Vim development Vim logo Vim Book Ad

VHDL indent ('93 syntax) : Revised VHDL indent file

 script karma  Rating 234/91, Downloaded by 8695  Comments, bugs, improvements  Vim wiki

created by
Gerald Lai
 
script type
indent
 
description
This VHDL indent file will help indent a VHDL file in Vim with the operator '='.
To indent the whole file, do 'gg=G'. See ":help ="

Previous good work has been done by N. J. Heo & Janez Strangelj (see vimscript#766). However, Heo & Strangelj's script was lacking in terms of alignment for assignment statements that continued on for more than one line, among other things.

This script covers a broad set of VHDL keywords, and performs proper alignment on port/generic mappings & on the RHS of assignment operators.

To disable alignment of generic/port mappings:
  :let g:vhdl_indent_genportmap = 0

To disable alignment of right-hand side assignment "<=" statements:
  :let g:vhdl_indent_rhsassign = 0

The two options above are enabled by default. To change them, place either of the above in ".vimrc".

In later versions of Vim 7.1 and above, access help documentation with:
  :help ft-vhdl-indent

Please send feedback and bug reports via e-mail. Much appreciated :)
 
install details
Copy "vhdl.vim" to either one of these indent directories:
  $HOME/.vim/indent/
  $VIMRUNTIME/indent/

Place this line in ".vimrc":
  :filetype indent on

 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vhdl.vim 1.62 2017-10-18 7.0 Gerald Lai Fix regression indenting type records

Incorporate shiftwidth() patch. Thanks Takuya Fujiwara!
vhdl.vim 1.60 2016-05-29 7.0 Gerald Lai Fix indentation of set of generic declarations.
Patch provided by Jacko Dirks.

Fix for port maps with bit-select in first port
Current version does not indent the following code
comp_inst : comp
port map (
a_in(0) => a, -- or a_in(1 downto 0) => a,
...
Patch provided by robin.

Thanks to both Jacko, and robin!
vhdl.vim 1.58 2011-09-28 7.0 Gerald Lai PORT-like indentation of PROCEDURE arguments
Better indenting for BEGIN and ELSIF/ELSE/END IF, etc.

Thanks to Tjaart Opperman!
vhdl.vim 1.56 2010-07-11 7.0 Gerald Lai Minor fix to correctly indent type record / units.
Better indenting for END;

Thanks to Angel Ezquerra.
vhdl.vim 1.54 2007-08-17 7.0 Gerald Lai Minor bug fix over v1.53
vhdl.vim 1.53 2007-08-16 7.0 Gerald Lai Full-line comments (lines that begin with "--") are aligned with the very previous line only if a whitespace follows after "--". In other words, the character that comes after "--" determines alignment.

This allows commented code to be distinguished from real comments.

Thanks to Christian Brehm again for the idea!
vhdl.vim 1.52 2007-08-07 7.0 Gerald Lai Critical bug FIXED: Alignment of code failed on indents with tabs. Realized that stridx() and matchend() read a tab as 1 space, instead of the correct &tabstop number of spaces. Thanks to Christian Brehm!

Renamed options to g:vhdl_indent_genportmap & g:vhdl_indent_rhsassign, to be consistent with naming convention.
vhdl.vim 1.50 2007-01-29 7.0 Gerald Lai Now, alignment of generic/port mappings and RHS assignment "<=" statements can be disabled in ".vimrc".
Minor improvements to keywords "end" + "component".
vhdl.vim 1.40 2006-06-13 7.0 Gerald Lai Improved indenting for keyword "end".
vhdl.vim 1.36 2006-04-12 7.0 Gerald Lai No change to main code. Just commented out code for "[[", "]]", etc. motion & matchit configuration, because they rightfully belong to the VHDL ftplugin. Also removed auto-indenting when typing "--" comment - it was more annoying than helpful.
vhdl.vim 1.34 2006-02-11 6.0 Gerald Lai Small change: Improved '[[', ']]', '[]', '][' motions. Motions now accept a count (e.g. indent 3 blocks '=3]['). Motions also ignore comments now, and work for visual-type modes.
vhdl.vim 1.3 2006-01-31 6.0 Gerald Lai Made more robust for various code layout.
Fixed "else" keyword in conditional statement bug.
Many other tweaks applied.
vhdl.vim 1.2 2006-01-26 6.0 Gerald Lai Minor fixes:
Keyword "report" handling added.
Better handling of keyword "for".
Resolved "<=" confusion between signal assignment & less-than operator.
Made some matches more robust.
vhdl.vim 1.1 2006-01-25 6.0 Gerald Lai Many major fixes:
Generic/Port/Map statements alignment
Generic Map no semicolon oddity accounted for
Case-When alignment when one-line When statements are present
Comments are smart-aligned now (be sure to do indenting at least twice)
Accommodated more coding styles (VHDL people are a diverse bunch ;))
and many more.
vhdl.vim 1.0 2006-01-24 6.0 Gerald Lai Initial upload
ip used for rating: 34.236.152.203

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github