我想清理一些javascript文件并用很好的缩进等重新格式化它们,是否有建议公用事业在Windows下执行此操作?
是否有任何命令行(非交互式,不是基于Web的)工具将重新格式化(精美打印)PHP和Javascript代码?
当使用Ctrl + Shift + F在Eclipse中自动格式化JSP文件时,它试图尽可能多地在一行上标记,然后不适合它的标记将断开并将属性放在下一行.
这是创建非常混乱的代码,例如下面.
<div class="type-text"><label for="echo">Project Name: </label> <s:textfield
id="projectName"
name="projectName"
value="Project Name"
>
</s:textfield></div>
Run Code Online (Sandbox Code Playgroud)
有谁知道如何更好地格式化JSP文件?
我试图使用vim 7.2(在Windows XP上)自动缩进和格式化一些VHDL和Matlab代码.为此,我尝试使用"gg = G"命令.但是这不能正常工作.代码没有正确缩进.
举个例子,我有以下源代码,它已经正确缩进:
% This function is based on the code_g_generator() function
function [v_code] = get_code(n_code_number)
% There is no need to clear the persistent variables in this function
mlock
%% Initialize the internal variables
persistent n_fifo_top;
if isempty(n_fifo_top)
n_fifo_top = 1;
end
N_MEMORY_SIZE = 4;
if n_code_number > 4
c_saved_code_fifo = {-1*ones(1, N_MEMORY_SIZE)};
end
Run Code Online (Sandbox Code Playgroud)
如果我使用"gg = G"命令,我得到:
% This function is based on the code_g_generator() function
function [v_code] = get_code(n_code_number)
% There is no need to …Run Code Online (Sandbox Code Playgroud) 我试图找到编写PHP的最佳实践.
我只是想知道这是一个坏习惯.
例如,处理变量.
$var = 1
$var = doSomething($var);
$var = doSomething2($var);
$var = doSomething3($var);
Run Code Online (Sandbox Code Playgroud)
看起来有点可怕.
这是我刚才做的真实代码的示例:
$this->rSum = explode(",", $this->options["rSum"]);
$this->rSum = array_combine(array_values($this->rSum), array_fill(0, count($this->rSum), 0));
Run Code Online (Sandbox Code Playgroud)
如果有人可以通过我一些编写更干净的代码的好教程,那将是很好的!
它让我再次提出愚蠢的问题.:)
顺便说说..
模型中可以进行多少自动处理?
我有一个具有执行方法的模型,当我调用它时,它会执行许多操作,例如读取定义文件和进行数据库查询.
例如
$object = new Object()
$object->setFile("example.txt");
$object->execute();
// Then i can fetch things from it
echo $object->getName();
Run Code Online (Sandbox Code Playgroud) 如何更改基本的Resharper缩进选项?我注意到Resharper的缩进设置与VS 2010不同 - VS使用四个空格进行缩进,而且很难说Resharper使用了什么 - 但我的代码左边距是锯齿状的.
我想重置Resharper以使用与VS 2010相同的设置,但我找不到选项.
哪些可以找到?
在Visual Studio 2010中键入以下内容后,
using(var myEntities = new MyEntities())
{
IQueryable<Employee> employees =
from e in myEntities.Employees
where e.Name == name &&
e.Password == hasher.ComputeHash(password)
select e;
... Code left out for simplicity ...
Run Code Online (Sandbox Code Playgroud)
当我进入右大括号时遇到格式问题.具体来说,文本编辑器重新格式化我的linq查询中的空格,以便我最终得到,
using(var myEntities = new MyEntities())
{
IQueryable<Employee> employees =
from e in myEntities.Employees
where e.Name == name &&
e.Password == hasher.ComputeHash(password)
select e;
... Code left out for simplicity ...
}
Run Code Online (Sandbox Code Playgroud)
是否可以在Visual Studio的格式设置中更改某些内容以防止我的linq查询中的空格被自动删除?我已经尝试了谷歌搜索,我已经浏览了Visual Studio的工具 - >选项窗口,但无法找到任何内容.希望我只是忽视了一些事情......
提前谢谢了!
什么是Sql Server Management Studio中用于格式化代码的Ctrl + K + D(Visual Studio)?
在使用内联括号表示法时,是否有任何常用的约定如何格式化长依赖列表?在浏览了github和Angular JS开发人员指南之后,我还没有看到一致的方法.
我对个人认为最好的事情不感兴趣(对不起),但是如果有某些我无法找到的标准惯例或最佳实践.
这是有效的,但它扩展到第212列.快速比较字符串和参数也很困难.
angular.module('donkey', []).controller('FooCtrl', ['$scope', '$http', 'someCoolService', 'anotherCoolService', 'somethingElse', function ($scope, $http, someCoolService, anotherCoolService, somethingElse) {
}]);
Run Code Online (Sandbox Code Playgroud)
它仍然在第87列,但很容易比较字符串和args.
angular
.module('donkey', [])
.controller('FooCtrl', [
'$scope', '$http', 'someCoolService', 'anotherCoolService', 'somethingElse',
function ($scope, $http, someCoolService, anotherCoolService, somethingElse) {
}]);
Run Code Online (Sandbox Code Playgroud)
我倾向于使用这个,因为它水平紧凑,允许快速注释掉依赖项.但是,它确实看起来有点奇怪.
angular
.module('donkey', [])
.controller('FooCtrl', [
'$scope',
'$http',
'someCoolService',
'anotherCoolService',
'somethingElse',
function (
$scope,
$http,
someCoolService,
anotherCoolService,
somethingElse) {
}])
Run Code Online (Sandbox Code Playgroud)
有没有一种方法可以满足JSLint的空白检查,并且还可以在Sublime Text 3中维护代码崩溃功能?
谢谢!
由于ESLint,我在返回语句之前找到了关于空行的返回规则.但是在功能中的第一个语句之前没有看到关于空行的规则.铁:
function (a) {
var b = +a;
}
Run Code Online (Sandbox Code Playgroud)
ESlint对此有规定吗?如果有,这条规则的名称是什么?谢谢
code-formatting ×10
javascript ×4
php ×2
angularjs ×1
auto-indent ×1
coding-style ×1
eclipse ×1
editor ×1
eslint ×1
indentation ×1
jsp ×1
linq ×1
resharper ×1
vim ×1