In the Code Community, we have several projects related to editing shapes by dragging vertices, snapping to other vertices etc. While we don't have a project showing the exact case you have, we have something pretty similar in Snap To Layer. You will see how you can drag a vertex of a line and snap it to a vertex of a polygon within a certain tolerance. I think that from this sample, you can easily adapt for your case.
code.thinkgeo.com/projects/show/snaptolayer
You can also check other projects related to editing layers showing other techniques such as:
code.thinkgeo.com/projects/show/draggedpointstyle
code.thinkgeo.com/projects/s...stylelabel
code.thinkgeo.com/projects/show/snappingtovertex
You will find different techniques for manipulating and editing layer. Keep in mind that for all your editing need the key class here is the EditInteractiveOverlay.
I realize that one of your requirements is to have the ability to add and remove vertices from a a line. We don't have a project showing specifically that but this is a good idea for a new project in the Code Community. We will soon work on publishing a project for that in the Code Community. Thank you for your idea.