A good exercise for you fretted string players when you’re learning a song, play the melody on only one string while repeating the names of the notes out loud. Not just the fret numbers, but the note names themselves either with letter names (I.e. C#, D, E) or using solfège (di, ré, mi)
Do it on all of the strings your instrument has. It’s okay if you need to adjust the melody line to fit slightly if it exceeds the upper or lower range of the string, just make sure it sounds good. Make sure you take note of what strings the melody fits best on in that key
This helps you develop familiarity with the fretboard as well as laying out the melody in a more logical way, allowing you to see where the tonal centers are on each string in that key.
Once you’re able to do that try doing it on only two strings. Experiment with where in the melody and on the fretboard it’s convenient/comfortable to switch strings. Limiting yourself like this forces you to develop an awareness of the ways you like to finger certain sequences of notes.
If you do this for every song you learn in every key, you’ll be well on your way to being able to play anything you want anywhere on the fretboard in any key.












