Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement emacs-style join_lines #92

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Default.sublime-keymap
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
{"keys": ["ctrl+l"], "command": "sbp_center_view"},
{"keys": ["ctrl+x", "g"], "command": "sbp_goto_line"},
{"keys": ["alt+g"], "command": "sbp_goto_line"},
{"keys": ["super+shift+6"], "command": "sbp_join_lines"},

// Goto open file
{"keys": ["ctrl+x", "ctrl+f"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
Expand Down
25 changes: 25 additions & 0 deletions jove.py
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,31 @@ def run_cmd(self, util):
view.insert(util.edit, point.b, "\n")
view.run_command("move", {"by": "characters", "forward": False})

class SbpJoinLinesCommand(SbpTextCommand):
def run_cmd(self, util):
if util.state.argument_supplied:
forward = True
else:
forward = False
view = self.view

def join(cursor):
if not forward:
current_line = view.line(cursor)
view.run_command("move", {"by": "lines", "forward": False})
cursor = view.sel()[0]
if view.line(cursor) == current_line:
# must be on the first line; do nothing
return None
else:
# Move to end-of-line
current_line = view.line(cursor)
cursor = sublime.Region(current_line.b, current_line.b)
view.run_command("join_lines")
return view.sel()[0]

util.for_each_cursor(join)

class SbpKillRegionCommand(SbpTextCommand):
is_kill_cmd = True
def run_cmd(self, util, is_copy=False):
Expand Down
1 change: 1 addition & 0 deletions sbp.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
{"caption": "Sublemacs - Go to Line", "command": "sbp_goto_line"},

{"caption": "Sublemacs - Open line", "command": "sbp_open_line"},
{"caption": "Sublemacs - Join Lines", "command": "sbp_join_lines"},
{"caption": "Sublemacs - Center View Around Point", "command": "sbp_center_view"},

//
Expand Down