8.1 C
United States of America
Sunday, November 24, 2024

improvement – XCode : Easy methods to use cmd + x to both lower the present line (if no textual content is chosen) or lower the chosen textual content


I’ve discovered an answer by combining Higher Contact Device and @Francois reply. It is attainable to make use of a single shortcut that inspects the lively component and triggers shortcut A if there may be some textual content chosen, and shortcut B if there is not.

This instance depends on having related ⌘x with the native Lower motion in Xcode and ⇧⌘x with Lower Present Line within the talked about reply.

  1. In BTT, add an Xcode override (the left panel)
  2. Choose Keyboard Shortcuts (the highest panel)
  3. Create a brand new keyboard shortcut, e.g. ⌘x
  4. Add a brand new block in the correct panel, and depart it as “No Motion” and chosen.
  5. Paste this there:
[
  {
    "BTTActionCategory" : 0,
    "BTTIsPureAction" : true,
    "BTTPredefinedActionType" : 330,
    "BTTPredefinedActionName" : "If Condition",
    "BTTIfConditionFormat" : "focused_element_details CONTAINS "AXSelectedText (W):  """",
    "BTTIfConditionData" : "YnBsaXN0MDDUAQIDBAUGBwpYJHZlcnNpb25ZJGFyY2hpdmVyVCR0b3BYJG9iamVjdHMSAAGGoF8QD05TS2V5ZWRBcmNoaXZlctEICVRyb290gAGvEBYLDBMYICorLTQ4PT5BRUlOT1JYXGBiVSRudWxs0w0ODxAREl8QF05TQ29tcG91bmRQcmVkaWNhdGVUeXBlXxAPTlNTdWJwcmVkaWNhdGVzViRjbGFzcxABgAKAFdIUDxUXWk5TLm9iamVjdHOhFoADgBTUDxkaGxwdHh9fEBFOU1JpZ2h0RXhwcmVzc2lvbl8QEE5TTGVmdEV4cHJlc3Npb25fEBNOU1ByZWRpY2F0ZU9wZXJhdG9ygBOADoAEgBHVISIjJA8lJicoKVlOU09wZXJhbmReTlNTZWxlY3Rvck5hbWVfEBBOU0V4cHJlc3Npb25UeXBlW05TQXJndW1lbnRzgAaABRADgAiADVx2YWx1ZUZvcktleTrSIw8QLIAH0i4vMDFaJGNsYXNzbmFtZVgkY2xhc3Nlc18QEE5TU2VsZkV4cHJlc3Npb26jMDIzXE5TRXhwcmVzc2lvblhOU09iamVjdNIUDzU3oTaACYAM0w8jOTo7PFlOU0tleVBhdGiACxAKgApfEBdmb2N1c2VkX2VsZW1lbnRfZGV0YWlsc9IuLz9AXxAcTlNLZXlQYXRoU3BlY2lmaWVyRXhwcmVzc2lvbqM_MjPSLi9CQ15OU011dGFibGVBcnJheaNCRDNXTlNBcnJhedIuL0ZHXxATTlNLZXlQYXRoRXhwcmVzc2lvbqRGSDIzXxAUTlNGdW5jdGlvbkV4cHJlc3Npb27TSiMPS0xNXxAPTlNDb25zdGFudFZhbHVlgA8QAIAQXxAXQVhTZWxlY3RlZFRleHQgKFcpOiAgIiLSLi9QUV8QGU5TQ29uc3RhbnRWYWx1ZUV4cHJlc3Npb26jUDIz1A9TVFVWTExXWk5TTW9kaWZpZXJXTlNGbGFnc15OU09wZXJhdG9yVHlwZYASEGPSLi9ZWl8QFU5TSW5QcmVkaWNhdGVPcGVyYXRvcqNZWzNfEBNOU1ByZWRpY2F0ZU9wZXJhdG9y0i4vXV5fEBVOU0NvbXBhcmlzb25QcmVkaWNhdGWjXV8zW05TUHJlZGljYXRl0i4vRGGiRDPSLi9jZF8QE05TQ29tcG91bmRQcmVkaWNhdGWjY18zAAgAEQAaACQAKQAyADcASQBMAFEAUwBsAHIAeQCTAKUArACuALAAsgC3AMIAxADGAMgA0QDlAPgBDgEQARIBFAEWASEBKwE6AU0BWQFbAV0BXwFhAWMBcAF1AXcBfAGHAZABowGnAbQBvQHCAcQBxgHIAc8B2QHbAd0B3wH5Af4CHQIhAiYCNQI5AkECRgJcAmECeAJ_ApECkwKVApcCsQK2AtIC1gLfAuoC8gMBAwMDBQMKAyIDJgM8A0EDWQNdA2kDbgNxA3YDjAAAAAAAAAIBAAAAAAAAAGUAAAAAAAAAAAAAAAAAAAOQ",
    "BTTEnabled2" : 1,
    "BTTOrder" : 1076
  },
  {
    "BTTActionCategory" : 0,
    "BTTIsPureAction" : true,
    "BTTLayoutIndependentActionChar" : "x",
    "BTTShortcutToSend" : "56,55,7",
    "BTTEnabled2" : 1,
    "BTTOrder" : 1077
  },
  {
    "BTTActionCategory" : 0,
    "BTTIsPureAction" : true,
    "BTTPredefinedActionType" : 333,
    "BTTPredefinedActionName" : "Else",
    "BTTEnabled2" : 1,
    "BTTOrder" : 1078
  },
  {
    "BTTActionCategory" : 0,
    "BTTIsPureAction" : true,
    "BTTLayoutIndependentActionChar" : "x",
    "BTTShortcutToSend" : "55,7",
    "BTTEnabled2" : 1,
    "BTTOrder" : 1079
  },
  {
    "BTTActionCategory" : 0,
    "BTTIsPureAction" : true,
    "BTTPredefinedActionType" : 334,
    "BTTPredefinedActionName" : "END If Condition",
    "BTTEnabled2" : 1,
    "BTTOrder" : 1080
  }
]

The consequence ought to seem like this:
CMD + X forking shortcut

This is the worth used within the If clause for focused_element_details in case you add it manually:

AXSelectedText (W):  ""

The If block is identical for all shortcuts, so simply copy and paste it.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles