The actively maintained Solidity plugin for Vim.
Comprehensive syntax highlighting, indentation, and code folding for Solidity, the smart contract programming language for Ethereum. Supports Solidity 0.8.x with all modern language features.
- ✅ Modern Solidity 0.8.x support: All keywords through Solidity 0.8.24
transientstorage (0.8.24+)uncheckedblocks (0.8.0+)- Custom
errordeclarations (0.8.4+) - User-defined value types (
type Foo is uint256, 0.8.18+) using ... globalsyntax (0.8.19+)fallback()andreceive()functions
- ✅ Smart indentation: Context-aware indentation for functions, contracts, and blocks
- ✅ Code folding: Fold contracts, functions, and assembly blocks
- ✅ NatSpec support: Syntax highlighting for
@param,@return,@notice, etc. - ✅ Yul/Assembly: Full Yul opcode highlighting with proper scoping
- ✅ Foundry integration: Automatic detection of
.t.soland.s.solfiles - ✅ Pure Vim: No external dependencies, works in Vim 8.0+ and Neovim
Add to your ~/.vimrc or ~/.config/nvim/init.vim:
Plug 'thesis/vim-solidity', { 'branch': 'main' }Then run :PlugInstall
Add to your ~/.vimrc:
Plugin'thesis/vim-solidity'Then run :PluginInstall
git clone https://github.com/thesis/vim-solidity.git ~/.vim/bundle/vim-soliditymkdir -p ~/.vim/pack/plugins/start
git clone https://github.com/thesis/vim-solidity.git ~/.vim/pack/plugins/start/vim-solidity{
'thesis/vim-solidity',
branch='main',
ft='solidity',
}Add to your ~/.vimrc:
augroupsolidity_foldingau!auFileTypesoliditysetlocalfoldmethod=syntaxaugroupENDUsage:
zc- Close fold under cursorzo- Open fold under cursorzM- Close all foldszR- Open all folds
vim-solidity works with vim-commentary:
Plug 'tpope/vim-commentary'Usage:
gcc- Toggle comment on current linegcin visual mode - Toggle comment on selection
Enable % jumping between Solidity constructs:
" In your .vimrcruntime macros/matchit.vimSupported matches:
contract↔}function↔}if↔elsetry↔catchassembly↔}
vim-solidity detects Foundry projects automatically:
.t.solfiles → Test files.s.solfiles → Script files- Regular
.solfiles → Contract files
A buffer-local variable b:solidity_file_type is set to 'test', 'script', or 'contract'.
All modern Solidity features are highlighted:
// Custom errors (0.8.4+)error InsufficientBalance(uint256available, uint256required);
// User-defined value types (0.8.18+)type UFixed256x18isuint256;
// Using global (0.8.19+)using SafeMathforuint256global;
// Transient storage (0.8.24+)contractExample {
transient uint256 temporaryValue;
// Unchecked arithmetic (0.8.0+)function increment(uint256x) publicpurereturns (uint256) {
unchecked {
return x +1;
}
}
}Full support for Solidity's documentation format:
/// @title A title/// @author The author name/// @notice Explain to end users what this does/// @dev Explain to developers the extra details/// @param x Description of parameter x/// @return Description of return valuefunction example(uint256x) publicreturns (uint256) {
return x *2;
}Assembly blocks have proper syntax highlighting with scoped opcodes:
function getCodeSize(addressaddr) publicviewreturns (uint256size) {
assembly {
size :=extcodesize(addr)
}
}- Vim: 8.0 or later
- Neovim: Fully compatible
- Solidity: 0.8.0 through 0.8.24+ (backward compatible with 0.7.x)
This is a pure Vim plugin focused on syntax, indentation, and folding. It does not provide:
- Language Server Protocol (LSP) features (go-to-definition, hover, rename)
- Linting (use ALE or Syntastic)
- Code completion (use LSP or YouCompleteMe)
- Compiler integration (planned for future release)
For full IDE features, you can set up an LSP client (coc.nvim, vim-lsp, or native Neovim LSP) with a Solidity language server like nomicfoundation/solidity-language-server.
| Feature | vim-solidity (this) | tomlion/vim-solidity |
|---|---|---|
| Actively maintained | ✅ Yes | ❌ Abandoned (5+ years) |
| Vim support | ✅ Yes | ✅ Yes |
| Neovim support | ✅ Yes | ✅ Yes |
| Solidity 0.8.x | ✅ Yes | ❌ Partial |
| Pure Vim | ✅ Yes | ✅ Yes |
Use vim-solidity if:
- You want actively maintained Solidity syntax support
- You need modern Solidity 0.8.x features
- You prefer a simple, dependency-free plugin
- You work on remote servers via SSH
- You want syntax highlighting and code folding that "just works"
For LSP features:
If you need go-to-definition, hover, rename, and other IDE features:
- Set up an LSP client (coc.nvim, vim-lsp, or native Neovim LSP)
- Use a Solidity language server like nomicfoundation/solidity-language-server
- vim-solidity works alongside LSP for syntax highlighting
Your colorscheme may not define Solidity-specific groups. Try a different colorscheme or customize:
" In your .vimrchilinksolKeywordStatementhilinksolBuiltinTypeTypehilinksolConstantConstantThe indentation logic is based on JavaScript. For complex cases, you may need to manually adjust with >> and <<.
Please report persistent indentation issues with a minimal example.
Make sure you've set foldmethod:
:setfoldmethod=syntaxIf folding is slow, try:
:setfoldmethod=indentContributions are welcome! See CONTRIBUTING.md for guidelines.
# Clone vader.vim for testing
git clone https://github.com/junegunn/vader.vim.git test/vader.vim
# Run tests
vim -Nu test/vimrc -c 'Vader! test/vader/*.vader'Before opening an issue:
- Check existing issues for duplicates
- Test with a minimal
.vimrc - Provide a minimal Solidity example
- Include your Vim version and OS
Use our issue templates.
- Foundry - Ethereum development toolkit
- solc - The Solidity compiler
- Hardhat VSCode - Official Solidity LSP implementation
- coc.nvim - LSP client for Vim/Neovim
- vim-lsp - Async LSP client for Vim
This plugin is a maintained fork of tomlion/vim-solidity, which has been inactive since 2018. It incorporates improvements from the Ethereum Foundation's fork and adds modern Solidity 0.8.x support.
MIT License - see LICENSE for details.
⭐ If you find vim-solidity useful, please star the repository!
Built with ❤️ for the Solidity and Vim communities.