在vim中,f<space>
和F<space>
分别将光标向前移动到下一个空格,然后向后移动到前一个空格。
Sublime Text 3中是否有相同的命令?如果是这样,请在密钥绑定中证明其用途。
答案 0 :(得分:1)
将以下代码保存到:
/Packages/MoveToSpace/MoveToSpace.py
import sublime, sublime_plugin
class MoveToSpaceCommand( sublime_plugin.TextCommand ):
def run( self, edit, mode ):
view = self.view
selections = self.view.sel()
if len( selections ) == 0:
return
newSelections = []
for selection in selections:
spacePoint = None
if mode.lower() == "forward":
spacePoint = self.view.find( "[^ ] " , selection.end() ).a
if spacePoint != -1:
newSelections.append( sublime.Region( spacePoint + 1, spacePoint + 1 ) )
elif mode.lower() == "backward":
spaceRegions = self.view.find_all( " [^ ]")
spaceRegion_Count = len( spaceRegions )
for index in range( 0, spaceRegion_Count ):
if spaceRegions[ index ].b < selection.begin():
spacePoint = spaceRegions[ index ].a
elif spaceRegions[ index ].b >= selection.begin() \
and spacePoint != None:
newSelections.append( sublime.Region( spacePoint + 1, spacePoint + 1 ) )
break
if len( newSelections ) > 0:
view.sel().clear()
view.sel().add_all( newSelections )
将以下代码保存到:
/Packages/MoveToSpace/Default.sublime-keymap
[
{
"keys": [ "ctrl+shift+=" ],
"command": "move_to_space",
"args": { "mode": "forward" },
},
{
"keys": [ "ctrl+shift+-" ],
"command": "move_to_space",
"args": { "mode": "backward" },
},
]
包含的键绑定是:
您可以更改键绑定以符合您的偏好。
答案 1 :(得分:0)
Ctrl + Left &amp; Ctrl + Right 按字边界移动插入符号,包括空格。
您可以通过修改l, h, j, k, W, w, e, E, b, B, alt+w, alt+W, $, ^, %, 0, G, gg, f, F, t, T, ^f, ^b, H, M, L
值来更改User Settings中指定字边界的字符。
Sublime Text还有Vintage Mode,模仿了VIM的许多功能,包括:
eval