Daniel Daly, 24, inflicted a head wound on his victim in a street assault with the "fearsome weapon".
Paul McDonnell, 33, was left scarred on the face and with part of a finger missing following the attack, which was caught on CCTV.
The High Court in Edinburgh heard that Daly had served in Iraq and Northern Ireland, but was discharged from the army after he was the victim of an earlier assault.
Defence counsel Paul McBride, QC, said: "This is a man who has given of himself in the service of his country. He was sufficiently highly regarded to be allowed into the community to recruit others. He found it difficult to reconcile his career in the army coming to an end.
"The reports available are eloquent of his struggle to come to terms with being discharged from the army in 2008."
Mr McBride said Daly had also worked with vulnerable youngsters and testimonials for him had been provided to the court.
Judge Lady Stacey told Daly: "I accept you have served your country in Northern Ireland and in Iraq and been decorated for that. I also accept that you have found the transition back to civilian life difficult. However, I have to have regard to law and order. You went out in the middle of the night armed with a sword to confront Mr McDonnell, with whom you had issues. That behaviour is completely unacceptable."
The judge said she had been shown a samurai sword during Daly's earlier trial and added: "It is a fearsome weapon." She told Daly that in the circumstances she had to impose "a lengthy custodial sentence".
Daly, formerly of Burnbank, Hamilton, had earlier denied attempting to murder Mr McDonnell on 16 March this year in the Lanarkshire town.
Mr McDonnell said he was carrying a wooden clothes pole or stretcher, when a white van came to a halt further down the street. He said a man emerged from the van carrying a sword and they ran towards each other.
"I got in with the wooden stretcher first and then got hit on the face and on my hands. I lost a fingertip on my right hand," he said. "When I realised the extent of my injuries, I fled. Seconds later, I looked in the street light and my face was almost hanging off."
Mr McBride said that the victim had discharged himself from hospital after the attack and "seems untroubled by what happened to him". The defence counsel said Daly had been "deeply traumatised" by the death of a young man who had killed himself and there seemed to be a suggestion the victim had made remarks relating to that.