Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jiangmiao/simple-javascript-indenter
A vim javascript indent script
https://github.com/jiangmiao/simple-javascript-indenter
Last synced: 4 months ago
JSON representation
A vim javascript indent script
- Host: GitHub
- URL: https://github.com/jiangmiao/simple-javascript-indenter
- Owner: jiangmiao
- Created: 2010-09-03T15:51:16.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2016-02-25T19:09:12.000Z (over 8 years ago)
- Last Synced: 2024-01-15T17:48:17.380Z (5 months ago)
- Language: VimL
- Homepage: http://www.vim.org/scripts/script.php?script_id=3227
- Size: 274 KB
- Stars: 72
- Watchers: 4
- Forks: 8
- Open Issues: 7
-
Metadata Files:
- Readme: README.mdown
- Changelog: ChangeLog
Lists
- my-awesome-starred - jiangmiao/simple-javascript-indenter - A vim javascript indent script (Vim Script)
README
Simply Javascript Indenter
==========================
A simple vim indent plugin for javascript, support OOP, jqueryInstall details
---------------copy indent/javascript.vim to ~/.vim/indent
Options
-------
* g:SimpleJsIndenter_BriefMode (default 0)
> set 1 to turn brief mode on.About Brief Mode
----------------
Add 'let g:SimpleJsIndenter_BriefMode = 1' to ~/.vimrc to use brief mode.In Brief Mode script will not indent more than one shiftwidth each line.
eg:
For a lot of people prefer set shiftwidth to 4, so in normal mode, it will indent looks like
each(function {
........something(); // indent 2 shiftwidth
});
(((
............something(); // indent 3 shiftwidth
)));In brief mode it will indent as
each(function {
....something(); // indent 1 shiftwidth
});
(((
....something();
)))ATTENTION:
Be sure to always close the brackets with the same level as open, or the after code will not indent correctly.
eg:
function() {
....each(function() {
....} // should use }); instead of }
); // already indented..
something();
}About Indenting in switch {}
----------------------------
It's not a perfect indenting.
see https://github.com/jiangmiao/simple-javascript-indenter/issues#issue/2Indent Effects
--------------
/*
* Comment Test
* function() {
*/
{
/* a [{( */
// b [{(
comment('/* com', a /* [{( */); /* c */ // d
ok();
// Assign Test
var a, /* { */
b, // [
c = '{'
var a = "Hello" +
"World"
d = function() {
aoeu
}
var k = function() {
var k=3,
m=4
}var rurl = /{[('"/,
r20 = /%20/g,a = 1,
b = 2
a = 1 +
2 *
3
}// Function nested
;(function($) {
$(document).ready(function() {
$('#foo').click(function() {
$.post(url, {
a: 1,
b: 2,
}, function() {
ok();
}
);
});
});
})(jQuery);// Array Object Test
string_test("('",'("',"[",'{',"\"{","\\'{");
{
array_object_test: [
1,
2,
{
a: [3,4],
b: [
3,
4
],
c: string_test("('",'("',"[",'{',"\"{","\\'{"),
function_test: function() {
return 0;
},
one_line_function_test: function() { return [1] }
}
]
}// One Line Test
{
if( a == b &&
c == d ||
e == f)
{
ok();
}
if(a) {
b;
} else {
e;
}
if(a)
b;
else if(k) {
aeou
} else
c;
while(true)
foo += 1;
try
a;
catch
b;
finally
c;
ok();
}