移至 Android Studio 中的 previous/next 函数(Vim 模拟器)
Move to the previous/next function in AndroidStudio (Vim Emulator)
我是 vim 用户,最近我开始学习为 Android 编写应用程序。
我使用 Android Studio 2.3.2 和 Vim 模拟器。
谈到 Vim- 我通常将它用于 C++ 编程,我每天使用的功能之一是 ] ] 移动到下一个函数,[[ 移动到上一个函数。
当我在 Android Studio 中使用它时,它只是将我移动到文件的 beginning/end。
我的猜测是它与在同一行而不是在新行中打开函数范围有关。
问题:
是否可以使用 Android Studio Vim 模拟器跳转到 next/previous 函数,就像我以前在 C++ 代码中所做的那样(即使我使用 Java 编码样式,a.k.a。"egyptian brackets")?
来自文档 :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 用户,最近我开始学习为 Android 编写应用程序。
我使用 Android Studio 2.3.2 和 Vim 模拟器。
谈到 Vim- 我通常将它用于 C++ 编程,我每天使用的功能之一是 ] ] 移动到下一个函数,[[ 移动到上一个函数。
当我在 Android Studio 中使用它时,它只是将我移动到文件的 beginning/end。
我的猜测是它与在同一行而不是在新行中打开函数范围有关。
问题:
是否可以使用 Android Studio Vim 模拟器跳转到 next/previous 函数,就像我以前在 C++ 代码中所做的那样(即使我使用 Java 编码样式,a.k.a。"egyptian brackets")?
来自文档 :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