An open API service indexing awesome lists of open source software.

https://github.com/abougouffa/emacs-vim-file-locals

Set Emacs editor options from Vim modeline
https://github.com/abougouffa/emacs-vim-file-locals

Last synced: 4 months ago
JSON representation

Set Emacs editor options from Vim modeline

Awesome Lists containing this project

README

          

* vim-file-locals

This is an Emacs package that adds support for Vim's modelines. =vim-file-locals=
is inspired by [[https://github.com/cinsk/emacs-vim-modeline][vim-modeline]], but supports more Vim modelines and makes use of
=editorconfig= to set some mode-specific options.

When you open a file that includes Vim's modelines, =vim-file-locals= ensures
applying the right Emacs options that matches the modelines' ones.

For example, when we open a file containing this line at the beginning/end of
the file:

#+begin_src elisp
;; -- Elisp
;; vim: set ts=8 tw=120 ft=el:
#+end_src

=vim-file-locals= will parse the line and set =fill-column= to 120, =tab-width= to 8
and it will set the mode to =emacs-lisp-mode= (based on the =el=, which is
interpreted by =vim-file-locals= as a file extension or a mode name).

Supported Vim modeline options are:

| Modeline options |
|-------------------------------------------|
| =filetype= =ft= |
| =syntax= =syn= |
| =shiftwidth= =sw= |
| =textwidth= =tw= |
| =tabstop= =ts= |
| =softtabstop= =sts= |
| =encoding= =enc= |
| =fileencoding= =fenc= |
| =fileformat= =ff= |
| =readonly= =ro= |
| =modifiable= =ma= |
| =number= =nu= =nonumber= =nonu= |
| =expandtab= =et= =noexpandtab= =noet= |
| =linebreak= =lbr= =nolinebreak= =nolbr= |
| =smartindent= =si= =nosmartindent= =nosi= |
| =autoindent= =ai= =noautoindent= =noai= |
| =relativenumber= =rnu= =norelativenumber= =nornu= |
|-------------------------------------------|

** Installation
Using Emacs' 30+ built-in =use-package='s =:vc= keyword:

#+begin_src elisp
(use-package vim-file-locals
:vc (:url "https://github.com/abougouffa/emacs-vim-file-locals" :rev :newest)
:hook (after-init . vim-file-locals-mode))
#+end_src

Or, using the =straight= package:

#+begin_src elisp
(use-package vim-file-locals
:straight (:host github :repo "abougouffa/emacs-vim-file-locals")
:hook (after-init . vim-file-locals-mode))
#+end_src

If you don't want to enable =vim-file-locals-mode= globally, you can use the =M-x
vim-file-locals-apply= command to extract and apply VIM's modeline options from
the current buffer.