diff --git a/web/pgadmin/static/js/components/CodeMirror.jsx b/web/pgadmin/static/js/components/CodeMirror.jsx
index 4141369d1..b1d76a00e 100644
--- a/web/pgadmin/static/js/components/CodeMirror.jsx
+++ b/web/pgadmin/static/js/components/CodeMirror.jsx
@@ -132,6 +132,7 @@ export const CodeMirrorInstancType = PropTypes.shape({
   addOverlay: PropTypes.func,
   setSelection: PropTypes.func,
   scrollIntoView: PropTypes.func,
+  getSelection: PropTypes.func,
 });
 
 export function FindDialog({editor, show, replace, onClose}) {
@@ -146,6 +147,12 @@ export function FindDialog({editor, show, replace, onClose}) {
 
   const search = ()=>{
     if(editor) {
+      // Get selected text from editor and set it to find/replace input.
+      let selText = editor.getSelection();
+      if(selText.length != 0) {
+        setFindVal(selText);
+      }
+
       let query = parseQuery(findVal, useRegex, matchCase);
       if(!query) return;
 
