我是一名vim用户,最近我开始学习为Android编写应用程序 我将Android Studio 2.3.2与Vim模拟器一起使用。
关于Vim-我通常将它用于C ++编程,我每天使用的一个功能是] ] 移动到下一个函数和 [ []进入上一个功能。
当我在Android Studio中使用它时,它只会将我移动到文件的开头/结尾。
我的猜测是,它与在同一行而不是在新行中打开函数范围有关。
问题:
是否可以使用Android Studio Vim模拟器跳转到下一个/上一个函数,就像我以前在C ++代码中所做的那样(即使我使用Java编码风格,又称"埃及括号")?
答案 0 :(得分:2)
来自文档:help ]]
*]]*
]] [count] sections forward or to the next '{' in the
first column. When used after an operator, then also
stops below a '}' in the first column. |exclusive|
Note that |exclusive-linewise| often applies.
这意味着它只是进入下一个语句,其中'{'作为该行的第一个字符,恰好是C和C ++函数(至少在某些样式中),因为方法和函数以{
,没有任何类型的嵌套。
但是,在编写Java时,方法嵌套在类中,这意味着它们通常具有缩进级别。
According to this answer,Vim具有内置的[m
和]m
映射,用于导航方法。
*]m*
]m Go to [count] next start of a method (for Java or
similar structured language). When not before the
start of a method, jump to the start or end of the
class. When no '{' is found after the cursor, this is
an error. |exclusive| motion.
因此,如果您希望使用[[
和]]
来导航方法,可以在~/.ideavimrc
重新映射这些方法。
nnoremap [[ [m
nnoremap ]] ]m