Vim Tips Wiki

Editing

Indenting for Java

1
  • The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit. If you are undoing an edit that is …
Latest revision Your text
Line 1: Line 1:
{{TipImported
+
  +
  +
{{Tip
 
|id=700
 
|id=700
|previous=699
+
|title=indenting for Java
|next=701
+
|created=April 14, 2004 23:58
|created=2004
 
 
|complexity=basic
 
|complexity=basic
|author=dunamin
+
|author=dunamin--AT--sbcglobal.net
 
|version=5.7
 
|version=5.7
 
|rating=6/9
 
|rating=6/9
|category1=Indenting
+
|text=
|category2=Java
+
I needed to do a few tweaks to .vimrc to get Java code looking smooth in vim and I'm passing the joy. This is probably good for at least 80% of Java programmers. Hope this helps my fellow Java/Vim peeps.
}}
 
I needed to do a few tweaks to vimrc to get Java code looking smooth in Vim.
 
   
My vimrc file:
+
Randy Solomonson
   
<pre>
+
My .vimrc file:
"Take care of indents for Java.
 
set autoindent
 
set si
 
set shiftwidth=4
 
"Java anonymous classes. Sometimes, you have to use them.
 
set cinoptions+=j1
 
</pre>
 
   
==Comments==
+
"Take care of indents for Java.
Also you can use
+
set autoindent
  +
set si
  +
set shiftwidth=4
  +
"Java anonymous classes. Sometimes, you have to use them.
  +
set cinoptions+=j1
   
<pre>
+
}}
let java_comment_strings=1
 
let java_highlight_java_lang_ids=1
 
</pre>
 
   
See help on java syntax highlighting file {{help|java}}.
+
== Comments ==
  +
Also you can use
  +
let java_comment_strings=1
  +
let java_highlight_java_lang_ids=1
   
  +
Get help on java syntax highlighting file:
  +
{{help|java}}
  +
  +
alexander_kurilovich--AT--hotmail.com
  +
, April 15, 2004 2:30
 
----
 
----
I use these settings too:
+
I use these settings too:
   
<pre>
+
let java_mark_braces_in_parens_as_errors=1
let java_mark_braces_in_parens_as_errors=1
+
let java_highlight_all=1
let java_highlight_all=1
+
let java_highlight_debug=1
let java_highlight_debug=1
+
let java_ignore_javadoc=1
let java_ignore_javadoc=1
+
let java_highlight_java_lang_ids=1
let java_highlight_java_lang_ids=1
+
let java_highlight_functions="style"
let java_highlight_functions="style"
+
let java_minlines = 150
let java_minlines = 150
 
</pre>
 
   
  +
'''Anonymous'''
  +
, April 15, 2004 6:34
 
----
 
----
Also, in [http://www.cygwin.com/ cygwin] or UNIX-based systems, there's a program called "astyle" which properly indents Java programs, just like cb or indent do for C programs.
+
Also, in cygwin (www.cygwin.com), there's a program called "astyle" which properly indents Java programs, just like cb or indent do for C programs.
   
  +
lyle_z--AT--hotmail.com
  +
, March 9, 2005 15:14
 
----
 
----
Prefer using <code>:setlocal</code> from a java ftplugin if you do not want to pollute all types of files with Java settings.
+
<!-- parsed by vimtips.py in 0.474011 seconds-->
   
----
+
  +
[[Category:Java]]
  Loading editor
Below are some commonly used wiki markup codes. Simply click on what you want to use and it will appear in the edit box above.

View this template