Author Topic: how to comment out code - keyboard shortcut  (Read 9725 times)

oneday

  • New Community Member
  • Posts: 2
  • Hero Points: 0
how to comment out code - keyboard shortcut
« on: November 09, 2014, 07:03:14 am »
I went through slickedit documentation and I cant seem to figure out the short-cut to comment out block of code

for example in notepad++ all i need to do is ctl+K to comment and uncomment the code. What would be similar short cut for slickedit

Documentation says - below which is not that helpful
To comment out a selected code block, from the main menu, click
Document > Comment Block
(or use the
box
command). This comments out the entire selection as a single block comment by
surrounding the block with comment characters you have specified in your comment settings.
• To comment out selected lines, from the main menu, click
Document > Comment Lines
(or use
the
comment
command). Each line in th
e selection is commented out as a single line comment. If
there is no selection, the current line is comment
ed out. If using a block selection where there are
partially selected lines, comment characters are placed at the beginning and end of the selection.
If using a character selection where there are pa
rtially selected lines,
comment characters are
placed based on your settings. The comment characters
that are placed to the left and right of the
text are also specified in your comment settings.
• To uncomment lines in a selection, from the main menu, click
Document > Uncomment Line
(or
use the
comment_erase
command). Surrounding line comment characters are removed from the
line. If there is no active sele
ction, the current line will be un
commented. Uncomme
nt Line only
works for well-formed comments, wh
ich means that every line in the selection is commented and
that the comment characters
occur in the
same column.
Whether you are creating a comment block or a comment line, if the selected text already contains
comments, another set of comment characters is added
. SlickEdit® attempts to preserve the i

Graeme

  • Senior Community Member
  • Posts: 2432
  • Hero Points: 322
Re: how to comment out code - keyboard shortcut
« Reply #1 on: November 09, 2014, 09:00:45 am »
When the help file refers to "box command" or "comment command" it actually means that "box" and "comment" are the names of commands.  You can type the name of a command on the slickedit command line and the command will be executed - or you can bind a key to a command and execute the command using that key sequence.

One way to find out what commands are available and what their keyboard shortcuts are is to open the options dialog  - select tools on the main menu then options -> keyboard and mouse -> key bindings.  Then in the "search by command" text box, enter "comment" - no quotes.  You'll see a list of commands related to comments and their keyboard shortcuts.  If you select a particular command you'll see some info on what that command does.  Unfortunately the "box" command doesn't appear there.  A better name for the "box" command would be "comment_block".

I think by default the "box" command and "comment" commands don't have keybindings - if they do, they will be shown in the menu you get when you click "Document" on the main menu.  To assign a key binding for the box command, in the key bindings dialog, type "box" (no quotes) in the "search by command" edit box, then click on the box command that appears in the list.  Then click the "Add" button, type the key sequence and click the bind button.

So to create a block comment, select a few lines, click Document on the main menu, then click "Comment Block".  Or, select a few lines then press the keyboard shortcut you assigned to the box command.  If you want line comments instead of a block comment, select a few lines then press the keyboard shortcut you assigned to the "comment" command.


jimlangrunner

  • Senior Community Member
  • Posts: 360
  • Hero Points: 31
  • Jim Lang - always a student.
Re: how to comment out code - keyboard shortcut
« Reply #2 on: November 09, 2014, 02:50:45 pm »
Let me add something - I think I read your question differently than Graeme.

I use the comment/uncomment a lot when doing SQL Work.  I would be unhappy without keyboard shortcuts this.  For simplicity, I tend to use line comments (not comment blocks) when I use the shortcuts.  YMMV.

Keyboard shortcuts can (and do) differ based on your emulation.  I use the Visual Studio emulation, so the key combinations:
Ctrl-K, Ctrl-C (Ctrl-K followed by Ctrl-C) comments the line I am on or the lines I have selected.
Ctrl-K, Ctrl-U (Ctrl-K followed by Ctrl-U) un-comments the line I am on or the lines I have selected.

A lot depends on your emulation and preferences.  If you do NOT have a keyboard shortcut for commenting/uncommenting lines, it is fairly easy to add one. 
Go to Tools -> Options
find Keyboard and Mouse -> keybindings
Search by command for "comment"
If keyboard shortcuts are assigned, you'll see them in the key Sequence in the grid.
If not, you can click the item, then click the "Add" button to add your preferred shortcut.  Before doing so, however, you will want to "Search by key sequence" to be sure your preferred shortcut is not already assigned to something else.

HTH - Jim.

oneday

  • New Community Member
  • Posts: 2
  • Hero Points: 0
Re: how to comment out code - keyboard shortcut
« Reply #3 on: November 09, 2014, 04:36:08 pm »
Jim - Thanks for the pointer I am able to add binding now for commenting with keyboard shortcut.

Having said that I find it highly amusing that no default shortcut is provided for such a basic functionality. Also if you try to bind you have to scratch ur head to come up with combination as some of the most common shortcut are used for other purposes which are the most uncommon things which someone seldom uses.

These part definitely needs a revisit from a product perspective - my 2 cents

jimlangrunner

  • Senior Community Member
  • Posts: 360
  • Hero Points: 31
  • Jim Lang - always a student.
Re: how to comment out code - keyboard shortcut
« Reply #4 on: November 09, 2014, 04:40:44 pm »
Well - it is already bound in some emulations.  While I'm no expert on every emulation, it seems they have gone to great lengths to match the shortcuts in the different emulations.  It's not perfect (as I know very well).  But it seems to be pretty good.

And you _can_ remove the keybinding on things you don't want/need/use if you want a keybinding for your own use.