You can retain any selection made in the Linedefs, Sectors and Things modes while moving from 2D editing to Visual mode (and back). To do this, hold Shift while going to/from Visual mode (that will be Shift-Q by default). You can also invert this behavior by enabling Preferences -> Editing -> "Synchronize selection between Visual and Classic modes" setting. When this setting is enabled, holding Shift will ignore selection.