移动到AndroidStudio(Vim Emulator)中的上一个/下一个功能
问题描述:
我是vim用户,最近我开始学习编写Android应用程序。
我使用Android Studio 2.3.2和Vim仿真器。移动到AndroidStudio(Vim Emulator)中的上一个/下一个功能
,因为它涉及到Vim-我通常用它为C++编程和我每天都在使用的功能之一是]]移动到下一个功能和[[得到到以前的功能。
当我在Android Studio中使用它时,它将我移动到文件的开始/结尾处。
我的猜测是它与在同一行而不是在新行中打开函数范围有关。
问:
这有可能采用Android Studio的Vim的模拟器,就像我以前在C++做代码(即使我使用Java编码风格,又名“埃及括号”跳到下一首/上功能)?
答
从文档: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
这就是为什么我爱vim。我认为自己是一个有经验的用户,但我不知道这个''m'和'[m'方法。奇迹般有效。谢谢 – lewiatan