No Description

Csaba Hoch bba638c6ff Merge pull request #42 from radarjones/master 6 days ago
ftdetect fc8fa1fe76 added .escript files 1 year ago
indent 54eb56a5bf Update "last update" dates and URLs 2 years ago
syntax 42cba6adb6 Highlight is_map_key as BIF 6 days ago
README.md 1f8a74ba27 Add installation instructions for vim-plug 3 years ago
helper.vim 44a531c85e helper.vim: Delete misleading comment 4 years ago
test_indent.erl 9bd90e2841 (#2) Fix multiple "-spec" clauses (if there is no "when") 5 years ago
test_indent_manual.erl 4bf1a2d43a (#10) Subsequent comment lines should align with the first one 5 years ago
test_indent_manual.vim 4bf1a2d43a (#10) Subsequent comment lines should align with the first one 5 years ago
test_indent_tabs.erl b1ad8a8d6b Handle tab characters in the source code 6 years ago
test_syntax.erl b6f66a17d0 (#33) Highlight Func in mod:Func as a variable 3 years ago

README.md

Erlang indentation and syntax for Vim

This is the Erlang indentation and syntax that is shipped with Vim (from Vim 7.4).

Installation

Method 1

  • Clone this repository:

    $ mkdir -p ~/.vim/bundle
    $ cd ~/.vim/bundle
    $ git clone https://github.com/vim-erlang/vim-erlang-runtime
    
  • Add the repository path to runtimepath in your .vimrc:

    :set runtimepath^=~/.vim/bundle/vim-erlang-runtime/
    

Method 2

  • Copy syntax/erlang.vim into ~/.vim/syntax/.
  • Copy indent/erlang.vim into ~/.vim/indent/.

Installing using vim-plug

  1. Install vim-plug using the instructions
  2. Add vim-erlang-runtime to your plugin list in .vimrc and re-source it:

    insert vim-erlang-runtime

    '' Erlang Runtime
    Plug 'vim-erlang/vim-erlang-runtime'
    

    between call plug#begin('~/.vim/plugged')

    and call plug#end()

  3. Run :PlugInstall

Development and testing

This section is relevant only if you want to be involved in the development of the script.

The indentation script can be tested in the following way:

  • Copy syntax/erlang.vim into ~/syntax.
  • Open test_indent.erl in Vim from this directory. (test_indent.erl always shows how the Erlang code is indented by the script – not how it should be.)
  • Source helper.vim (:source helper.vim)
  • Press F1 to load the new indentation (indent/erlang.vim).
  • Press F3 to reindent the current line. Press shift-F3 to print a log.
  • Press F4 to reindent the current buffer.
  • Press F5 to show the tokens of the current line.

Note:

  • When the indentation scripts detects a syntax error in test mode (i.e. when it was loaded with F1 from helper.vim), it indents the line to column 40 instead of leaving it as it is. This behavior is useful for testing.

Tip: indentation from the command line

The following snippet re-indents all src/*.?rl files using the indentation shipped with Vim:

vim -ENn -u NONE \
    -c 'filetype plugin indent on' \
    -c 'set expandtab shiftwidth=4' \
    -c 'args src/*.?rl' \
    -c 'argdo silent execute "normal gg=G" | update' \
    -c q

Notes:

  • This can be for example added to a Makefile as a "re-indent rule".
  • You can use the expandtab, shiftwidth and tabstop options to customize how to use space and tab characters. The command above uses only spaces, and one level of indentation is 4 spaces.
  • If you would like to use a different version of the indentation script from that one shipped in Vim (e.g. because you have Vim 7.3), then also add the following as the first command parameter:
  -c ':set runtimepath^=~/.vim/bundle/vim-erlang-runtime/'