gvim文本编辑器帮助_如何帮助您的文本编辑器帮助您

gvim文本编辑器帮助

by Evy

由Evy

如何帮助您的文本编辑器帮助您 (How to help your text editor help you)

编写更高效,更有趣的代码的提示和技巧 (Tips & tricks for writing more efficient and enjoyable code)

Over six internships, I’ve had lots of lovely mentors who have watched me code and let me watch them code. (I ? pair programming!) Thanks to them, there are lots of things I’ve learned on the job that have made my work more efficient and enjoyable.

在六个实习期间,我有很多可爱的导师,他们看着我编码,然后让我看着他们编码。 (我要进行空中编程! )多亏了他们,我在工作中学到了很多东西,使我的工作更加高效和有趣。

Some of these things are text editor tips and tricks, and I want to share some of what I’ve learned with you!

其中一些是文本编辑器的技巧和窍门,我想与您分享一些我学到的东西!

This is not a blog post about which text editor you should use. I’ll be sharing some examples in the editor I use these days (Sublime Text on a Mac) — but many text editors are customizable. That means that many of these tips & tricks can be probably be set up in your editor (and I’d love to see comments explaining how!) Let’s get rid of the “this tool is the best” discourse, and just learn how to help our tools help us better. ✨

这不是有关应该使用哪个文本编辑器的博客文章 。 我将在最近使用的编辑器中分享一些示例(在Mac上为Sublime Text),但是许多文本编辑器都是可自定义的。 这意味着可以在您的编辑器中设置许多提示和技巧(我很乐意看到解释方式的注释!)让我们摆脱“此工具是最好的”论述,而只是学习如何帮助我们的工具更好地帮助我们。 ✨

自动为您的代码添加代码 (Automatically lint your code)

Linters can be great for making code cleaner and easier to read, and for catching mistakes. Sometimes I run a linter after I finish a set of changes, or let a linter run online after I open a pull request on GitHub. But I got much faster at writing linter-passing code when the linter ran… as I wrote my code! I have not only stopped making boring tweaks for several minutes before submitting code. I’m also now training myself to fix issues before they even happen.

Linters可以使代码更清晰,更易于阅读,并且可以捕获错误。 有时,在完成一组更改后我会运行一个linter,或者在GitHub上打开一个pull请求后让一个linter在线运行。 但是当linter运行时,我在编写传递linter-pass的代码方面的速度大大提高了……在编写代码时! 在提交代码之前,我不仅停止了数分钟的无聊的调整。 我现在也在训练自己,以便在问题发生之前就将其修复。

80字规 (80 character ruler)

Speaking of arbitrary rules, lots of style guides like lines to be at most 80 characters long (or 100, or something else). Most text editors have a way to add a little line to remind you when you’re at that limit, whatever it is.

说到任意规则,许多样式指南都要求线段的长度最多为80个字符(或100个或其他字符)。 大多数文本编辑器都有一种方法可以添加一小行以提醒您何时达到此极限,无论它是多少。

自动遵循一些空白约定 (Automatically follow some whitespace conventions)

A lot of style guides prefer files to have no trailing whitespace and exactly one new line at the end of each file. It can be hard to remember to do this, so it’s nice when my text editor does it for me! Sublime has this in its user settings: “ensure_newline_at_eof_on_save” and “trim_trailing_white_space_on_save”.

许多样式指南都希望文件没有尾随空格,并且每个文件的末尾只有一行。 很难记住要执行此操作,因此当我的文本编辑器为我执行此操作时非常好! Sublime在其用户设置中具有以下内容: “ensure_newline_at_eof_on_save”“trim_trailing_white_space_on_save”

搜索(并替换)整个代码库 (Search (and replace) over the whole codebase)

When I’m dealing with a codebase of many files, it’s nice to search within it to see all the places something is used or referred to (⌘ shift F on MacOS in Sublime). It’s extra awesome to have the option to search specifically within a certain folder or file type. Sometimes I find it helpful to turn case sensitivity on/off or to use regular expressions — though I don’t use those features often.

当我处理包含多个文件的代码库时,最好在其中进行搜索以查看所有使用或引用过的地方((Sublime中的MacOS上的⌘ shift F )。 可以选择在特定的文件夹或文件类型中进行特定搜索是非常棒的。 有时,我发现打开/关闭区分大小写或使用正则表达式会有所帮助-尽管我并不经常使用这些功能。

快速查找功能定义 (Quickly find function definitions)

Sure, I could search through the codebase for a function name, find its definition, and then figure out how it works. But wouldn’t it be nice to have a way to get there faster?

当然,我可以在代码库中搜索一个函数名称,找到其定义, 然后弄清楚它是如何工作的。 但是,有一种更快到达那里的方法,不是很好吗?

快速查找文件 (Quickly find files)

I often want to find and open a file but don’t remember where exactly it is in the codebase. I love being able to enter the filename in a search bar and see all possible files I am looking for, which lets me open new files quickly. I love the added bonus of a really flexible search input. I can make a whole bunch of typos or leave out parts of the filename and Sublime still can figure out what I want! (I bet the tech behind that search algorithm, often called “fuzzy search”, is pretty interesting!)

我经常想找到并打开一个文件,但不记得它在代码库中的确切位置。 我喜欢能够在搜索栏中输入文件名并查看我正在查找的所有可能的文件,这使我可以快速打开新文件。 我喜欢真正灵活的搜索输入带来的额外好处。 我可以输入很多拼写错误,也可以忽略一部分文件名,Sublime仍然可以弄清楚我想要的是什么! (我打赌这种搜索算法背后的技术,通常称为“ 模糊搜索 ”,非常有趣!)

上下移动线 (Move line(s) up and down)

To move a line of code (or a whole function) below another, I used to use a lot of select + copy + paste. I’ve since figured out how to move lines up and down with a shortcut. It’s a small change, but I find it feels so much nicer (kinda like how amazing three finger drag feels).

要将一行代码(或整个函数)移到另一行下面,我曾经使用很多select + copy + paste。 从那以后,我就知道了如何使用快捷键上下移动行。 这是一个小的变化,但我觉得这感觉好多了 (有点像如何惊人的三周指拖动的感觉)。

语法高亮 (Syntax highlighting)

Syntax highlighting makes reading and scanning code much easier. But it also helps catch mistakes as they’re being typed — if it doesn’t look like it’s colored right, it might be a mistake.

语法突出显示使阅读和扫描代码更加容易。 但这也有助于在键入错误时发现错误-如果看起来颜色不正确,则可能是错误。

Sometimes syntax is highlighted by default. Sometimes only certain languages/technologies are in your default settings. I got a new work laptop and knew I needed to install a package to get jsx highlighting. Yet I still procrastinated it for a few months while working with many jsx files. After I took a minute to install it, things got so much better.

有时默认情况下语法突出显示。 有时,只有某些语言/技术处于您的默认设置中。 我有一台新的工作笔记本电脑,并且知道我需要安装一个软件包才能突出显示jsx 。 但是在处理许多jsx文件时,我仍然拖延了几个月。 我花了一分钟时间安装它之后,情况变得好多了。

Git的东西 (Git stuff)

Lastly, if you use git in your workflow, you can add some support to your text editor to tell you git-related things. One thing I like to see is what lines have been added/deleted/modified since my last commit (a lightweight git diff). I also sometimes use a tool (built around the poorly named git blame) to see who last changed a line in a file.

最后,如果您在工作流程中使用git,则可以向文本编辑器添加一些支持以告诉您与git相关的内容。 我喜欢看的一件事是自上次提交以来添加/删除/修改了哪些行(轻量级git diff )。 有时我还会使用一种工具(围绕名称不佳的 git blame构建)来查看谁最后更改了文件中的一行。

和更多! (And more!)

There are lots of cool things your text editor can do for you! I’m sure I’ll continue to learn about tools that will help me be more efficient and help my work be more enjoyable. And I don’t plan on starting to use them all at once — over time I will pick and choose tools as I get excited about them or find the need for them.

您的文本编辑器可以为您做很多有趣的事情! 我敢肯定,我将继续学习一些工具,这些工具将帮助我提高工作效率,并使我的工作更有趣。 而且,我不打算立即开始全部使用它们-随着时间的流逝,当我对它们感到兴奋或发现需要它们时,我会选择各种工具。

Hopefully some of these tips & tricks were exciting or helpful to you! I’d love to hear in the comments about what sorts of text editor features you love to use. ?

希望这些提示和技巧对您有帮助或对您有所帮助! 我很乐意在评论中听到您喜欢使用哪种类型的文本编辑器功能。 ?

翻译自: https://www.freecodecamp.org/news/helping-your-text-editor-help-you-24ea08adc6a6/

gvim文本编辑器帮助

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值