BURLINGTON, Vt. — When Bernie Sanders, a self-declared socialist, served as mayor here in the 1980s, he often complained that the United States had its priorities wrong, that it should be diverting money from the military to domestic needs like housing and health care.

So when dozens of antiwar activists blocked the entrance to the local General Electric plant because it was manufacturing Gatling guns to fight the socialists in Central America, the protesters expected the mayor’s full support.

Instead, he lined up with union officials and watched as the police made arrests, saying later that in blocking the plant, the activists were keeping workers from their jobs.

It was a classic example of how Mr. Sanders governed — as a pragmatist. He tended to talk globally but act locally, in this case choosing the real and immediate socialist principle of protecting workers over blocking the making of weapons to fight leftists abroad. Although he often shouted about foreign affairs, Mr. Sanders was consumed with running the city.