如何在输入代码时最小化使用箭头键? [英] How to minimize use of arrow keys when typing code?

查看:152
本文介绍了如何在输入代码时最小化使用箭头键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当输入代码时,我通常会关闭括号,回到里面,去外面,键入分号等:



我可以从:

  System.out.println 

然后向左:

  System.out.println(|)

>

  System.out.println(foo()|)

再次回溯一个空格:

  System.out.println(foo )

键入引号是类似的:

  System.out.println(foo(|))

...等。



我的右手不断在首页行和箭头键之间移动。我试过vim,虽然我知道基础,它仍然觉得非常尴尬对我来说。



我应该怎么做?我应该从左到右输入(开括号,然后是内容,然后是括号,然后是分号)?



谢谢。

h ,在Vim中获得很多速度> j k l 请参阅学习实践方法



但是,在这种情况下你可能想要的是 AutoClose 插件。它自动随着开头插入右括号(或引号),并在它们之间放置插入符号。因此,您从

  System.out.println(|)

  System.out.println(foo )

 code> System.out.println(foo(|))

类型)),插入符将移过结束字符,而不是插入新的。虽然,一个更快的方式到达行尾可能< c $ c>< Esc> A 。

  System.out.println(foo )); 

因此,总而言之,可以通过输入 System.out.println(foo(< Esc> A;



用于编辑字符,而不是插入它们,请参见 surround.vim 。 / p>

When typing code, I would normally close brackets, go back inside, go outside, type semicolon, etc:

I might start with (| is the caret):

System.out.println()|

Then go left:

System.out.println(|)

Then this:

System.out.println(foo()|)

Again backtracking a space:

System.out.println(foo(|))

Typing quotes are similar:

System.out.println(foo(""|))

...etc.

My right hand is constantly moving between the home row and the arrow keys. I've tried vim and although I know the basics, it still feels very awkward to me.

How should I do this? Should I just type from left to right (opening bracket, then contents, then closing brackets, then semicolon)?

Thanks.

解决方案

First and foremost, there is much speed to be gained in Vim by using h, j, k and l instead of the arrow keys. See Learning Vim the Pragmatic Way for a overview of the keys.

However, what you probably want in this case is the AutoClose plugin. It automatically inserts the closing parenthesis (or quote) along with the opening, and places the caret between them. Thus you go from

System.out.println(|)

to

System.out.println(foo(|))

to

System.out.println(foo("|"))

If you then type ")), the caret will "move over" the closing characters instead of inserting new ones. Although, a faster way to get to the end of line is probably <Esc>A.

System.out.println(foo(""));

So, to sum up, the above can be produced by typing System.out.println(foo("<Esc>A;.

For editing paired characters, as opposed to inserting them, see surround.vim.

这篇关于如何在输入代码时最小化使用箭头键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆