In vim, f<space>
and F<space>
move the cursor forward to the next space and backward to the previous space, respectively.
Is there a command in Sublime Text 3 that does the same? If so, please demonstrate its use in a key binding.
In vim, f<space>
and F<space>
move the cursor forward to the next space and backward to the previous space, respectively.
Is there a command in Sublime Text 3 that does the same? If so, please demonstrate its use in a key binding.
Ctrl + Left & Ctrl + Right moves the caret by word boundaries, including spaces.
You can alter the characters that dictate word boundaries in your User Settings by editing the word_separators
value.
Sublime Text also has Vintage Mode, which emulates many of VIM's functionalities including:
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
Save the following code to:
/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 )
Save the following code to:
/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" },
},
]
Included key-bindings are:
You can change the key-bindings to suit your preference.