如何在Vim中依次选择表达式的部分? [英] How do I sequentially select parts of an expression in Vim?

查看:173
本文介绍了如何在Vim中依次选择表达式的部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在Vim中有一个功能,我会发现如此伟大..请问是否存在,或者是否有人想知道如何开始实现? >'从数学的前端的 ctrl - 。功能启发,可以在视觉模式下顺序选择光标所在的表达式的连续层。例如,如果我们以假想的语言考虑以下表达式:

 #在此位置输入视觉模式:
for(i in 1:n){
a = append(a,b [i %% floor((n + 1)/ 2)] + c - n * last(a));
^
}
------------------------------------ ---------------------------------------------
2 #首选后的选定文字

(n + 1)/ 2#第二击

floor((n + 1)/ 2)#third hit

i %% floor((n + 1)/ 2)#第四击

b [i %% floor((n + 1)/ 2)]#第五击

b [i %% floor((n + 1)/ 2)] + c - n * last(a)#six hit

append(a,b [i %% floor +(1)/ 2)] + c - n * last(a))#第七击

a = append(a,b [i %% floor((n + 1)/ 2)] + c - n * last(a)); #8命中

(i in 1:n){
a = append(a,b [i %% floor((n + 1)/ 2)] + c - n *最后的(a)); `#等,直到整个文件被选中
}

我知道这将需要这个功能要知道各种运算符在langage和各自的优先级,但这不是太多的输入,是吗?



任何想法? p>

解决方案

默认情况下,Vim无法执行此操作,但至少有一个插件可以执行所需的操作: vim-expand-region


There is a feature in Vim I would find so great.. may I ask if it exists or if anyone had an idea about how I would start implementing it?

'Inspired from Mathematica's front end's ctrl-. feature, one would be able to sequentially select, in visual mode, the successive layers of an expression the cursor is taken into. For, example, if we consider the following expression in an imaginary langage:

# enter visual mode at this position:
for(i in 1:n){
    a = append(a, b[i %% floor((n + 1) / 2)] + c - n * last(a));
                                        ^
}
---------------------------------------------------------------------------------
2                                                                 # selected text after first hit

(n + 1) / 2                                                       # second hit

floor((n + 1) / 2)                                                # third hit

i %% floor((n + 1) / 2)                                           # fourth hit

b[i %% floor((n + 1) / 2)]                                        # fifth hit

b[i %% floor((n + 1) / 2)] + c - n * last(a)                      # sixth hit

append(a, b[i %% floor((n + 1) / 2)] + c - n * last(a))           # seventh hit

a = append(a, b[i %% floor((n + 1) / 2)] + c - n * last(a));      # eight hit

for(i in 1:n){
    a = append(a, b[i %% floor((n + 1) / 2)] + c - n * last(a)); `# etc. until the whole file gets selected
}

I am aware this would require the feature to be aware of the various operators in the langage and their respective precedences, but this is not too much of an input, is it?

Any idea?

解决方案

Vim can't do that by default but there is at least one plugin that does what you want: vim-expand-region.

这篇关于如何在Vim中依次选择表达式的部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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