I want to format the default style for text links—currently the color is blue & are underlined.
Is this possible? And if yes, how can I do it?
I just published a free add-on for precisely this task. It's called Link Style, and is available here.
It does not appear to be possible to update the default style for links in your Google doc. This is because Google docs does not treat links as styles. This is understandable, as a link might be applied within text formatted with any other style (e.g., Heading 1, normal text, etc.)
If you try highlighting a link and checking the context menu, note that the option is given to Update 'Normal Text' to match. This indicates that the style of the text is designated exclusively as 'Normal Text' (i.e., does not have a link style).
I really wanted to be able to change the default for links in the body text to prevent them being underlined. I realise that underlining links is a usability plus online, but aesthetically I felt that it often ruined the flow of a body of text within a document. My workaround is as follows.
This will remove underlines from all text in the document, including links.
This will remove underlines from all Normal Text, including links. You could alternatively use this to change the colour of links to the same as the body text, but you would have to leave the underlines in place, otherwise there would be no clue that the links were there.
I came across the same problem. All you need to do is alter the colour of the text the same way you would normal text.
Google doesn't seem to mind if it's a link or not.
I appreciate the solution by DavidR.
Below is a container-bound Google Apps Script that performs similar functions and can be added to your Google Doc.
Open your Google Docs file
Open the code editor by clicking on Extensions > Apps Script.
Clear the existing code from the editor and paste the following script the click Save:
function formatHyperlinks() {
var body = DocumentApp.getActiveDocument().getBody();
var searchResult = body.findText('.');
var linkColor = '#999999';
while (searchResult !== null) {
var element = searchResult.getElement();
var startOffset = searchResult.getStartOffset();
var endOffset = searchResult.getEndOffsetInclusive();
if (element.asText().getLinkUrl(startOffset) !== null) {
var text = element.asText();
text.setForegroundColor(startOffset, endOffset, linkColor);
text.setUnderline(startOffset, endOffset, false);
}
searchResult = body.findText('.', searchResult);
}
}
function onOpen() {
var ui = DocumentApp.getUi();
ui.createMenu('Auto format')
.addItem('Format hyperlinks', 'formatHyperlinks')
.addToUi();
}
Optionally, edit the script name.
You can run the script from the editor or use the "Format hyperlinks" menu item in the new "Auto format" menu the script adds to the document.
The first time you run your script you will be presented with an authorization pop-up.
text.setUnderline(startOffset, endOffset, false);
from the code.