- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我在 Visual Studio Code 中使用带有 TSLint 和 Prettier 的 TypeScript 来编写 React Native 应用程序。
我尝试将我的编辑器配置为自动将每行代码换行到 100 个字符。但保存后始终是 80 个字符,而不是 100 个。
以下是我更改的设置:
"prettier.tslintIntegration": true,
"prettier.printWidth": 100,
"editor.renderIndentGuides": true,
"editor.rulers": [100],
"editor.wordWrapColumn": 100,
"editor.formatOnSave": true
这是我的 tslint.json
:
{
"extends": ["tslint:recommended", "tslint-react", "tslint-config-prettier"],
"rules": {
// "jsx-no-lambda": false,
"member-access": false,
"interface-name": false,
"max-line-length": [true, 100]
}
}
即使我以这种方式配置了所有内容,我的代码仍然会自动换行大约 80 个字符。我怎样才能让它停止?
如果我的行超过 100 个字符,我会收到 linting 错误,因此 tslint.json
设置似乎有效。
奖励:完整的 VSCode 设置,以防我遗漏了什么:
{
"telemetry.enableTelemetry": false,
"workbench.colorTheme": "One Dark Pro",
"workbench.iconTheme": "vscode-icons",
"window.zoomLevel": 0,
"prettier.eslintIntegration": true,
"prettier.tslintIntegration": true,
"prettier.printWidth": 100,
"editor.renderIndentGuides": true,
"editor.rulers": [100],
"[javascript]": {
"editor.tabSize": 2
},
"[typescript]": {
"editor.tabSize": 2
},
"[typescriptreact]": {
"editor.tabSize": 2
},
"[json]": {
"editor.tabSize": 2
},
"workbench.colorCustomizations": {
// "statusBar.background": "#272b33",
// "panel.background": "#30353f",
// "sideBar.background": "#2a2b33",
"editor.background": "#2c313a"
},
"todohighlight.keywords": [
{
"text": "DEBUG:",
"color": "#fff",
"backgroundColor": "limegreen",
"overviewRulerColor": "grey"
},
{
"text": "NOTE:",
"color": "#fff",
"backgroundColor": "mediumslateblue",
"overviewRulerColor": "grey"
},
{
"text": "REVIEW:",
"color": "#fff",
"backgroundColor": "dodgerblue",
"overviewRulerColor": "grey"
},
{
"text": "XXX:",
"color": "#fff",
"backgroundColor": "orangered",
"overviewRulerColor": "grey"
}
],
"editor.wordWrapColumn": 100,
"editor.formatOnSave": true
}
最佳答案
这两个应该足够了:
"editor.wordWrap": "wordWrapColumn",
"editor.wordWrapColumn": 100
您的设置中似乎缺少 "editor.wordWrap"
。在 vscode 中,此设置控制换行策略:“wordWrapColumn”表示在 “editor.wordWrapColumn”
设置处换行。
您也可以尝试 "editor.wordWrap": "bounded"
,它会尊重“wordWrapColumn”,但如果您的视口(viewport)少于您定义的列数,也会换行。
UPD:根据我们在评论中的讨论,prettier 似乎不遵守其 "printWidth"
设置。可能有两个最可能的原因:
作为解决方法,您可以尝试在项目的 prettier 配置文件或 editorconfig 文件中实际定义此设置,并检查 vscode 插件是否适用于其中任何一个。
关于typescript - Visual Studio 代码和 TSLint : Code wrap to more than 80 characters,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52815047/
int i; System.out.print("Please enter a string: "); String string_1 = input.nextLine(); System.out
我想要一个正则表达式来检查 a password must be eight characters including one uppercase letter, one special charac
在此先感谢您的帮助。 在命令行输入“example”时,Python 返回“example”。我在网上找不到任何东西来解释这一点。所有引用资料都在 print 命令的上下文中谈到字符串,我得到了所有关
我有 CSV 格式的数据,这些数据在字符编码方面被严重打乱,可能在不同的软件应用程序(LibreOffice Calc、Microsoft、Excel、Google Refine、自定义 PHP/My
我正在为 Latex 使用 Sublime Text,所以我需要使用特定的编码。但是,在某些情况下,当我粘贴从不同程序(大多数情况下为单词/浏览器)复制的文本时,我收到以下消息: "Not all c
在 flutter 中,我使用了一个php文件,该文件从数据库查询返回json响应,但是当我尝试解码json时,出现此错误: E/flutter ( 8294): [ERROR:flutter/lib
我在 Flutter 项目中遇到异常。错误如下所示: Exception has occurred. FormatException (FormatException: Unexpected char
这个问题已经有答案了: Why doesn't my compare work between char and int in Java? (4 个回答) 已关闭 3 年前。 我试图在我的代码中找出
我在 Flutter 项目中遇到异常。错误如下所示: Exception has occurred. FormatException (FormatException: Unexpected char
我是 python 新手,需要一些帮助。我应该编写一个脚本,从键盘读取单词,直到输入单词 999。对于除 999 之外的每个单词,报告该单词是否有效。如果单词的第一个字符等于最后一个字符,则该单词有效
我正在实现自己的词法分析器,并且刚刚了解了 C# 如何处理字 rune 字:https://msdn.microsoft.com/en-us/library/aa691087(v=vs.71).asp
我有这个字符串: var test = "toto@test.com"; 我想用空值替换“@”字符后的所有字符。我想得到这个字符串: var test = "toto" 最佳答案 试试这个: test
我将数据库从 sqlite 更改为 postgresql 以用于我网站的生产,但出现此错误。当我在本地使用 sqlite 时,它没有出现这个错误。使用 Django。 ProgrammingErr
我正在为我的实验表制作凯撒密码,并使其能够加密 3 代入(凯撒密码),这是练习的重点。但是有一件事困扰着我。首先,如果我输入 3 以外的字符,则有一个尾随字符。例如,输入“恶意软件”,然后输入 2 作
遵循 this question 中的逻辑,以下代码应该有效: #include int main(){ printf("%c", '\0101'); return 0; } 然而,
我在处理一段代码时遇到错误: Too many characters in character literal error 使用 C# 和 switch 语句遍历字符串缓冲区并读取标记,但在这一行中出
给定一个元素,其值为: Distrib = SU & Prem <> 0 我要转<或 >进入 <或 >因为下游应用程序需要
从表面上看,他们似乎都在做同样的事情。但似乎是后者as(,"character")更强大。 作为示例,请考虑以下内容: library(rvest) temp % html_node("div p")
我刚开始使用python,所以很可能只是在做一些愚蠢的事情。我正在从表中读取数据,需要将它们放入txt文件的列中。我无法说服我的代码创建新行。 这是我的代码- file = open("test_m.
在尝试刷新我的项目的 Fortran 90 知识时,我在使用内部文件时遇到了一些奇怪的情况。考虑示例代码: ! ---- internal_file_confusion.f90 ---- progra
我是一名优秀的程序员,十分优秀!