1

Is there equivalent plugin like modeline_magic from VIM?

So each file could look like e.g.:

/* vim: set tabstop=8:softtabstop=8:shiftwidth=8:noexpandtab */ 
int main(int, char *) {}

and indentation would be passed to other clients?

1 Answer 1

7

You can add local (file) variables by having a line formatted as

-*- mode: modename; var: value; ... -*-

at the start of your file. Any number of var: value; pairs can appear in the line. If you're finding that you have too many local variables, you can change the style to

 # Local Variables:  
 # mode: python      
 # comment-column: 0 
 # End:              

Emacs searches for the string "Local Variables", and is smart enough to work out that the prefix and suffix (in this case # and nothing) should be reused for the following lines. This means that if the file is something other than python, you can change the prefix/suffix to match the different comment characters, e.g. /* and */ for ANSI C.

You can read more at the emacs manual.

4
  • I am afraid I have to say it once again my life: Emacs is incredible! Thanks!
    – test30
    Commented May 11, 2014 at 22:54
  • @test30 If this post answers your question, why not accept it? :)
    – itsjeyd
    Commented May 12, 2014 at 20:36
  • @itsjeyd you are right, I forgot about checking as accepted :D
    – test30
    Commented May 13, 2014 at 11:15
  • @event_jr I think you should post this editorconfig.org as a separate answer, because it's worth spreading it! What a pity it is not supported by Netbeans, at least it is not listed on website. actually "here":blogs.oracle.com/geertjan/entry/editorconfig_and_netbeans_ide is a plugin which supports it.
    – test30
    Commented May 13, 2014 at 11:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.