Skip to content

Instantly share code, notes, and snippets.

@ihabunek
Last active January 16, 2019 13:56
Show Gist options
  • Save ihabunek/81e6e59bbacbd4a7f40f0a673cf56fc9 to your computer and use it in GitHub Desktop.
Save ihabunek/81e6e59bbacbd4a7f40f0a673cf56fc9 to your computer and use it in GitHub Desktop.

Line selection

The URL hash (fragment) describes the selected lines. Examples:

hash description
#L10 single line
#L10,15,20 multiple lines
#L10-15 span of lines
#L10-15,20-25 multiple spans
#L10,15-20,30 combination of above

Clicking behaviour

What happens when a line number is clicked?

Plain click

Selection is cleared and the clicked line is selected.

The clicked line is remembered as last-clicked, used when selecting spans.

Ctrl+click

The line is added to current selection.

Examples:

Current selection Line clicked New selection
10 #L10
#L10 20 #L10,20
#L10-20 30 #L10-20,30

Alt+click

If last-clicked line exists, the span between last-clicked and the clicked line is added to the selection.

Current selection Last clicked Line clicked New selection
10 20 #L10-20
#L10 15 20 #L10,15-20

Questions:

  • what if last-clicked is empty?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment