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
- Host: GitHub
- URL: https://github.com/abougouffa/emacs-vim-file-locals
- Owner: abougouffa
- License: gpl-3.0
- Created: 2025-06-03T22:59:22.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-07-25T21:59:01.000Z (11 months ago)
- Last Synced: 2025-10-26T22:26:30.564Z (8 months ago)
- Language: Emacs Lisp
- Size: 74.2 KB
- Stars: 6
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE
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.