What's the difference in using between "almost" and "nearly"? In what cases they can be used interchangeably and in which ones they can't?
Nearly can almost always be replaced with almost. However, there is a rare use of nearly to mean closely (ODO gives the example "more nearly related", meaning "more closely related" - here "almost" wouldn't work).
In its other, more common usage, nearly has the same meaning as almost, although perhaps almost is slightly stronger. (ODO, the full OED and Collins all define "almost" as "very nearly" - although all three also define "nearly" as "almost".)
Most of the time when we say almost, we could just as well say nearly. However, almost also has a use that nearly doesn't.
Even though ODO only gives one definition for almost, the word nearly would work as a substitute in some of the examples it gives and not in others.
For example, either word could be used in these sentences:
‘he almost knocked Georgina over’
‘the place was almost empty’
‘blues, jazz—he can play almost anything’
But almost is the only possibility in the following examples:
‘There was almost a sense that if we did not say the word the problem would go away.’
‘The waters of Loch an Eilean were flat calm and the stillness of the air almost eerie.’
‘It was almost as if the local wildlife had decided to put on a show just to entertain us.’
In the sentences above, almost doesn't mean "nearly". It means something more like "more or less".
Cambridge explains that:
We use almost (but not nearly) to soften statements:
- I almost wish I hadn’t offered to pay his fine.
We use almost before any and before negative words such as no, none, never, nobody, nothing. We don’t use nearly in this way:
Using this special software, you can find the history of almost any building.
They’ve almost no confidence that they can use the new phone properly.
She almost never raises her voice.
To my ear, I don't think "nearly any" sounds unacceptable, but "nearly no" and "nearly never" are distinctly unidiomatic.
A brief addition to @rjpond's answer:
- In negative sentences, it's nearly, not almost, that can be used:
I nearly didn’t make it to work on time today.
Also, nearly is used in the "not nearly as [adjective] as" construction:
He’s not nearly as smart as he thinks he is.
Nearly is usually followed by numbers, e.g., nearly 200 people.
Almost may often be followed by adverbs and adjectives, e.g., almost always, almost certainly, almost impossible.