The main thing is to realize that in Manhattan the sidewalks generally operate like automobile traffic. You will find it easy to blend in if you handle yourself in much the same way that you do with your car. So, to start as you are coming out of a building you should enter slowly and look both directions.
Once you merge with the flow you need to be constantly scanning your surroundings, taking care to be aware of oncoming traffic as well as people behind you wanting to pass. Walking more than two abreast is a pretty bad idea. There are few places where that is possible for more than a minute or two at a stretch. If you do walk side by side you need to be able to switch to single file in an instant. Eventually you learn to carry on a conversation, have it abruptly interrupted, and then pick back up on it as the situation dictates. Apply the rules of the road to the sidewalk. Just as you would never suddenly stop on the highway you should not do that as a pedestrian either. Check behind you and step aside just like you would go to the shoulder. If you are in a group and have a sudden need for a conference try to consider your fellow walkers and gather in a spot out of the main flow.
In dense crowds like Times Square and rush hour you will get through much faster and with less frustration if you let someone else blaze the trail. Take note of someone moving about the speed you want to be going and just sort of shadow them. They will likely be taking a winding path rather than the usual straight line but if you stick with them you will find it is like coasting or drafting and your mental strain will drop.
Another good pointer is to walk against the car traffic if possible. Usually there are many alternatives in choosing a route to your destination. Nearly all the streets in Manhattan are one-way so if you have two options that are otherwise equal always take the one that is opposite the car traffic. This way when you are at crosswalks the cars turning on the red lights will be doing so in front of you where you can easily see what is happening instead of behind you where your attention is unnecessarily divided.
This leads right into the most critical part of walking safety, the crosswalk. The crosswalk may appear to be simple but it is one of the more complicated functions of Manhattan. At your first encounter you naturally look both ways before crossing and almost immediately realize this is a one way street. Don’t worry as no one else notices. The natives are too busy playing their game of “see who can cross the street first”. They are busy looking at a dozen or more different cues for when it is safe or at perhaps just less dangerous. Don’t follow them unless you are fluent in the art. In fact don’t even go with the herd without looking way down the road for one last cab trying to make the light. The herd saw that cab and knows it can cross. Keep in mind that, as far as I know, there Is no such thing as a speed limit in Manhattan. At least I have never seen a speed limit sign anywhere. That straggling cab can be on you in no time. After a while you will become adept at crossing against the light but don’t be in a big hurry.
Another crossing hazard is the bicyclist or the pedicab. They are supposed to follow the rules that apply to other vehicles of the road but occasionally a scofflaw will go the wrong way and/or run red lights. Near misses are an all too frequent occurrence and can have disastrous results.
When the light does change it will be like two dams bursting at once and you will be part of one tidal wave faced with passing through the opposing tidal wave. It will go smoother than you would think. Instead of crashing into a gridlock the two groups magically swirl through each other like schools of fish. A few seconds later the bunch will spread out and you will be back to the routine of the sidewalk, ready for the next crosswalk encounter as the cycle repeats.
There is no other place that requires a pedestrian to be so attentive. You must constantly scan and reassess your situation as carefully as driving a car in rush hour highway traffic. But with time and diligence you will eventually get into the flow and choreography of the process and you will no longer even think about what you are doing.