Simple but super useful, I think.
ctrl + (whatever)
- higlighted text is cut and placed into clipboard
- Text previously in clipboard replaces text from step one
LOVE SUBLIME and THANKS
Simple but super useful, I think.
ctrl + (whatever)
LOVE SUBLIME and THANKS
Just to learn it myself, I have crafted this python script.
The script:
[code]# Sublime Text v3 Python plugin, v00.1, StS, 2014-07-07
import sublime, sublime_plugin
class SwapSelectionWithClipboardCommand(sublime_plugin.TextCommand):
def run(self, edit):
#>>
# Get clipboard content
CurrClip = sublime.get_clipboard()
for region in self.view.sel():
#>>
# Get the selected text
mySel = self.view.substr(region)
if not region.empty():
#>>
#print(‘Swap_Sel_with_Clip, exchange Sel: "’ + mySel + ‘" with Clip: "’ + CurrClip + ‘"’)
# Replace the selection with new text
self.view.replace(edit, region, CurrClip)
#<< <<
# Put the origin selection on the clipboard
#print(‘Swap_Sel_with_Clip, put Sel: "’ + mySel + ‘" onto Clipbaord.’)
sublime.set_clipboard(mySel)
#c+s+d
[/code]
Save script as
“\SublimeText\Data\Packages\User\own_Swap_Selection_With_Clipboard.py”
Add keyboard shortcut
Menu “Preferences > Keybindings - User”
{ “keys”: “ctrl+shift+d”], “command”: “swap_selection_with_clipboard” },
TEST IT:
Copy this example text into sublime to a new document:
[code]Microsoft Windows [Version 6.1.7601]
Copyright © 2009 Microsoft Corporation. All rights reserved.
C:\Windows\System32>sqlcmd[/code]
Copy the word “Sublime” to Clipboard.
Select the word(s) “Microsoft” (Ctrl+D)
[code]Microsoft Windows [Version 6.1.7601]
Copyright © 2009 Microsoft Corporation. All rights reserved.
C:\Windows\System32>sqlcmd[/code]
Execute script (Ctrl+Shift+d)
Result:
[code]Sublime Windows [Version 6.1.7601]
Copyright © 2009 Sublime Corporation. All rights reserved.
C:\Windows\System32>sqlcmd[/code]
And vice versa, while still selected, execute script again
Result:
[code]Microsoft Windows [Version 6.1.7601]
Copyright © 2009 Microsoft Corporation. All rights reserved.
C:\Windows\System32>sqlcmd[/code]
HTH?
…