有人可以用简单的语言向我解释根据文件类型更改Vim的缩进行为的最简单方法吗?例如,如果我打开一个Python文件,它应该缩进2个空格,但如果我打开一个Powershell脚本,它应该使用4个空格.
Jinja2和Mako显然都非常快.
这些比较如何(功能较少但可能对我正在做的事情足够好)string.Template?
我一直在推动PowerShell中的.NET框架,我遇到了一些我不理解的东西.这很好用:
$foo = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]"
$foo.Add("FOO", "BAR")
$foo
Key Value
--- -----
FOO BAR
Run Code Online (Sandbox Code Playgroud)
然而,这不是:
$bar = New-Object "System.Collections.Generic.SortedDictionary``2[System.String,System.String]"
New-Object : Cannot find type [System.Collections.Generic.SortedDictionary`2[System.String,System.String]]: make sure t
he assembly containing this type is loaded.
At line:1 char:18
+ $bar = New-Object <<<< "System.Collections.Generic.SortedDictionary``2[System.String,System.String]"
Run Code Online (Sandbox Code Playgroud)
他们都在同一个集会,所以我错过了什么?
正如答案中指出的那样,这只是PowerShell v1的一个问题.
Google阅读器是否有API?如果是这样,我如何知道特定用户知道其用户名和密码的未读帖子数量?
所以,在询问这个问题之前,我确实搜索了谷歌和SO.基本上我有一个DLL,它有一个编译成它的表单.表单将用于向屏幕显示信息.最终它将是异步的,并在dll中暴露了大量的自定义.现在我只想让它正确显示.我遇到的问题是我通过在Powershell会话中加载它来使用dll.因此,当我尝试显示表单并让它到达顶部并具有焦点时,显示在所有其他应用程序上没有问题,但我不能在我的生活中让它显示在Powershell窗口上.这是我目前用来尝试显示的代码.我确信,一旦我弄明白,大多数都不会被要求,这只是代表我通过谷歌找到的所有东西.
CLass Blah
{
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
[DllImport("user32.dll", EntryPoint = "SetForegroundWindow")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("User32.dll", EntryPoint = "ShowWindowAsync")]
private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
private const int WS_SHOWNORMAL = 1;
public void ShowMessage(string msg)
{
MessageForm msgFrm = new MessageForm();
msgFrm.lblMessage.Text = "FOO";
msgFrm.ShowDialog();
msgFrm.BringToFront();
msgFrm.TopMost = true;
msgFrm.Activate();
SystemParametersInfo((uint)0x2001, 0, 0, 0x0002 | 0x0001);
ShowWindowAsync(msgFrm.Handle, WS_SHOWNORMAL);
SetForegroundWindow(msgFrm.Handle);
SystemParametersInfo((uint)0x2001, 200000, 200000, 0x0002 …Run Code Online (Sandbox Code Playgroud) 有没有人知道用于F#开发的IDE不会让我卖掉300美元?我很乐意转到F#VS Express,如果他们发布了一个,但花钱开始使用新语言不在我的预算范围内.
我搜索过,但显然我的谷歌foo很弱.我需要的是一种在控制台中提示用户输入并在一段时间后请求超时并在没有输入的情况下继续执行脚本的方法.尽管我已经知道,Read-Host不提供这个功能.$ host.UI.PromptForChoice()也不是$ host.UI.RawUI.ReadKey().提前感谢任何指针.
编辑:非常感谢Lars Truijens找到答案.我已经采用了他指出的代码并将其封装到一个函数中.请注意,我实现它的方式意味着在用户点击密钥和脚本执行继续之间可能存在长达一秒的延迟.
function Pause-Host
{
param(
$Delay = 1
)
$counter = 0;
While(!$host.UI.RawUI.KeyAvailable -and ($counter++ -lt $Delay))
{
[Threading.Thread]::Sleep(1000)
}
}
Run Code Online (Sandbox Code Playgroud) 我见过的每个编码标准都对一行中的字符数有建议或绝对限制.在这个限制范围内有各种各样的工作方式,但我没有看到这方面的任何具体指导.
显然,如果可能的话,不要写过长的行.
但是,如果这不实用呢?如何处理长线?
这里有几个例子
if ($Stmt = $Mysqli->prepare("SELECT color, pattern, size,
manufacturer, mfgSku, storeLocation,
aisle, status
FROM tblItems WHERE ourSku = ?")) {
Run Code Online (Sandbox Code Playgroud)
要么
$flavors = array ('chocolate', 'strawberry', 'vanilla', 'cookie dough',
'chocolate chip', 'mint chocolate chip', 'rocky road',
'peach', 'fudge brownie', 'coffee', 'mocha chip');
Run Code Online (Sandbox Code Playgroud)
要么
$Stmt->bind_result( $this->_firstName,
$this->_lastName,
$this->_BillToAddress->address1,
$this->_BillToAddress->address2,
$this->_BillToAddress->city,
$this->_BillToAddress->state,
$this->_BillToAddress->zip,
$this->_BillToAddress->country,
$this->_email,
$this->_status,
$this->_primaryPhone,
$this->_mobilePhone );
Run Code Online (Sandbox Code Playgroud)
在每个示例中,冗长代码的缩进是不同的.这样做有更好或更"标准"的方式吗?额外的行总是应该以相同的方式缩进.或者这样可以吗?
powershell ×2
.net ×1
antlr ×1
api ×1
c# ×1
coding-style ×1
compression ×1
diff ×1
f# ×1
file ×1
ide ×1
indentation ×1
javacc ×1
jinja2 ×1
mako ×1
php ×1
python ×1
settings ×1
vim ×1
winforms ×1