Highlights the current line in the editor; really simple.
You can now also underline the the current lines thanks to@sniperbat. This isn't enabled by default, andyou can edit the colour and type of line.
May 29, 2017 This is intended as a quick reference and showcase. For more complete info, see John Gruber's original spec and the Github-flavored Markdown info page. Note that there is also a Cheatsheet specific to Markdown Here if that's what you're looking for. You can also check out.
When selecting more than one line of text, you can enable selection borders atthe top and bottom of the selections. This isn't enabled by default.Courtesy of @djak250
You can now toggle the highlighted line by: cmd+alt+H
You can now toggle the hiding the highlight on selecting text by: cmd+shift+alt+H
You can now toggle the underline by: cmd+alt+U
You can now toggle the selection borders by: cmd+shift+alt+U
I've moved this package to use the new decorations API and as such we can nolonger set arbitrary style on the lines. So, this means no more entering colours/opacity in the settings.
You can update the colours by either updating the line-colors.less
fileonce you've installed the package. Or by adding the following to your style.less
I don't use the .cursor-line
class as when you make selection on thesame line, you then lose the highlight.
To remove unused settings delete them from your config.cson
.
I know I can link to a specific line number on a file on a github repo (I'm sure I've seen this before)...
Can someone tell me how to do this?
6 Answers
Don't just link to the line numbers! Be sure to use the canonical URL too. Otherwise when that file is updated, you'll have a URL that points to the wrong lines!
How to make a permanent link to the right lines:
Click on the line number you want (like line 18), and the URL in your browser will get a #L18
tacked onto the end. You literally click on the 18
at the left side, not the line of code. Looks like this:
And now your browser's URL looks like this:
If you want multiple lines selected, simply hold down the shift key and click a second line number, like line 20. Looks like this:
And now your browser's URL looks like this:
Here's the important part:
Now get the canonical url for that particular commit by pressing the y
key. The URL in your browser will change to become something like this:
That link contains the actual SHA hash for that particular commit, rather than the current version of the file on master
. That means that this link will work forever and not point to lines 18-20 of whatever future version of that file might contain.
Now bask in the glow of your new permanent link. ;-)
update 9/29/2017: As pointed out by @watashiSHUN, github has now made it easier to get the permanent link by providing a ...
menu on the left after you select one or more lines. Please upvote @watashiSHUN's answer too.
update 3/25/2016: Case in point -- in the example above, I referred to the 'README' file in the url. Those non-canonical urls actually worked when this answer was written. But now those urls no longer work since README
was moved to README.md
. But the canonical URL with SHA hash still works, just as expected.
@broc.seib has a sophisticated answer, I just want to point out that instead of pressing y
to get the permanent link, github now has a very simple UI that helps you to achieve it
Select line by clicking on the line number or select multiple lines by downholding
shift
(same as how you select multiple folders in file explorer)on the right hand corner of the first line you selected, expand
...
and clickcopy permalink
- that's it, a link with selected lines and commit hash is copied to your clipboard:
https://github.com/python/cpython/blob/c82b7f332aff606af6c9c163da75f1e86514125e/Doc/Makefile#L1-L4
Click the line number, and then copy and paste the link from the address bar. To select a range, click the number, and then shift click the later number.
Alternatively, the links are a relatively simple format, just append #L<number>
to the end for that specific line number, using the link to the file. Here's a link to the third line of the git
repository's README
:
You can you use permalinks to include code snippets in issues, PRs etc.
References:
Many editors (but also see the Commands section below) support linking to a file's line number or range on GitHub or BitBucket (or others). Here's a short list:
Atom
Emacs
Sublime Text
Vim
Commands
- git-link - Git subcommand for getting a repo-browser link to a git object
- ghwd - Open the github URL that matches your shell's current branch and working directory
Related of how to link README.md
of github to specific lineNumber of code file
You have three cases
1- We can link to (custom commit)
But Link will ALWAYS link to old file version, which will NOT contains new updates in the master branch for example.
Example
https://github.com/username/projectname/blob/b8d94367354011a0470f1b73c8f135f095e28dd4/file.txt#L10
2- We can link to (custom branch) like (master-branch)
But Link will ALWAYS link to latest file version which will contains new updates
But take care, due to new updates, the link may pointer to invalid business line number.
Example
https://github.com/username/projectname/blob/master/file.txt#L10
3- github can NOT make AUTO-link to any file either to (custom commit) nor (master-branch)
Because of following business issues
- line business meaning, to link to it in the new file
- length of target highlighted code which can be changed