M command in Snippet

  • Advertisement ( why? )
     

    patyoung, 20th Aug 2012 3:28 am

    is there a way to incorporate a command into a snippet ?
    i would like to be able to add UNDO to my snippet list, but can't get it to work.

    • HTML-Kit Support, 20th Aug 2012 7:55 am

      On 8/20/2012 3:28 AM, patyoung wrote:

      is there a way to incorporate a command into a snippet ?
      i would like to be able to add UNDO to my snippet list, but can't get it to work.

      Hi,

      You can see some examples of invoking M... commands in "Tools > Keyboard
      shortcuts > Edit." But Undo is a special command because it may also
      have to undo whatever is done within a snippet/plugin so I wouldn't
      generally recommend calling undo from a plugin.

      If this doesn't answer your question, let me know what you're trying to
      do and I'll see if there's another way to do it.

      Chami

      • patyoung, 22nd Aug 2012 10:23 pm

        many times when i am writing code, i end up saying, no no no, that's all wrong. and under the edit tab is the undo (go back) arrow. and that works fine, if i'm in the edit tab. but if not, then it is change tabs etc.

        not a big deal, but i thought in some cases it might be more convenient.

        but what would be much better is if i could have hot keys that would, say, undo, and another to type in a string of text (like that blasted "<br />" in JS.

        pat

        • patyoung, 22nd Aug 2012 10:41 pm

          hey presto -
          no sooner asked for than, well i stumbled across the obvious.
          listed under keyboard shortcuts was <br />.

          so please ignore my previous post. now i can play around with shortcuts.

          • HTML-Kit Support, 22nd Aug 2012 10:48 pm

            On 8/22/2012 10:41 PM, patyoung wrote:

            hey presto -
            no sooner asked for than, well i stumbled across the obvious.
            listed under keyboard shortcuts was <br />.

            so please ignore my previous post. now i can play around with
            shortcuts.

            And I was a little too quick to reply to your previous message. Replied
            before seeing this :)

            Chami

        • HTML-Kit Support, 22nd Aug 2012 10:47 pm

          On 8/22/2012 10:23 PM, patyoung wrote:

          many times when i am writing code, i end up saying, no no no, that's
          all wrong. and under the edit tab is the undo (go back) arrow. and
          that works fine, if i'm in the edit tab. but if not, then it is
          change tabs etc.

          not a big deal, but i thought in some cases it might be more
          convenient.

          but what would be much better is if i could have hot keys that would,
          say, undo, and another to type in a string of text (like that blasted
          "<br />" in JS.

          pat

          Hi Pat,

          For inserting <br /> and other code snippets you can create a keyboard
          shortcut or a snippet ("File > Insert > Add new snippet").

          For Undo though, it might be easier to use the default Ctrl+Z shortcut
          or the right click menu option when the Edit tab isn't open.

          Chami

          • patyoung, 22nd Aug 2012 11:06 pm

            cntrl z is perfect. somewhere there is probably a list of shortcut keys, but i haven't stumbled across it yet.

            one thing tho, could you just point me in the general direction of how to make the cursor go back 1 space after executing the shortcut ?

            if i cntrl B to insert the <br />, it not only adds it, but executes it as an html command, leaving me to have to backspace to where i want to be.

            • HTML-Kit Support, 22nd Aug 2012 11:22 pm

              On 8/22/2012 11:06 PM, patyoung wrote:

              cntrl z is perfect. somewhere there is probably a list of shortcut
              keys, but i haven't stumbled across it yet.

              Most keyboard shortcuts are listed on the Help menu but it's a pretty
              long list. For primary commands, check out right hand side keyboard
              shortcuts on Edit menu.

              one thing tho, could you just point me in the general direction of
              how to make the cursor go back 1 space after executing the shortcut
              ?

              if i cntrl B to insert the <br />, it not only adds it, but executes
              it as an html command, leaving me to have to backspace to where i
              want to be.

              If you leave out the newline after <br /> it'll stay at the end of the
              tag. For example, changing:

               #@begin-shortcut "default" [key="Ctrl+B"]
               <br />
              
               #@end-shortcut "default"
              

              to:

               #@begin-shortcut "default" [key="Ctrl+B"]
               <br />
               #@end-shortcut "default"
              

              should do the trick. Or, you can explicitly set the caret position:

               #@begin-shortcut "default" [key="Ctrl+B", movecursor=1]
               <strong>|</strong>
               #@end-shortcut "default"
              

              Hope this helps.

              Chami

              • patyoung, 22nd Aug 2012 11:56 pm

                it's strange. this works if i pick it from the sidebar, but if i try to use a shortcut key pair, i get STX highlighted for Ctrl + B,
                and DC2 highlighted for Ctrl + R (trying an unused pair).

                it is the keyboard shortcut i am after.

                • HTML-Kit Support, 23rd Aug 2012 12:12 am

                  On 8/22/2012 11:56 PM, patyoung wrote:

                  it's strange. this works if i pick it from the sidebar, but if i try
                  to use a shortcut key pair, i get STX highlighted for Ctrl + B, and
                  DC2 highlighted for Ctrl + R (trying an unused pair).

                  it is the keyboard shortcut i am after.

                  That means the keyboard shortcuts aren't defined (or redefined).

                  I'd first make sure that there aren't any spaces in key="Ctrl+B"

                  Chami