diff --git a/greenclip.cabal b/greenclip.cabal
--- a/greenclip.cabal
+++ b/greenclip.cabal
@@ -3,7 +3,7 @@
 -- see: https://github.com/sol/hpack
 
 name:           greenclip
-version:        3.1.1
+version:        3.2.0
 synopsis:       Simple clipboard manager to be integrated with rofi
 description:    Simple clipboard manager to be integrated with rofi - Please see README.md
 category:       Linux Desktop
diff --git a/src/Clipboard.hs b/src/Clipboard.hs
--- a/src/Clipboard.hs
+++ b/src/Clipboard.hs
@@ -23,7 +23,6 @@
 import           System.Posix.Process     (forkProcess)
 
 import           Data.ByteString          (unpack)
-import qualified Data.Text                as T
 import           Foreign                  (alloca, castPtr, peek, peekArray)
 import           Foreign.C.Types          (CUChar)
 import           Foreign.Marshal.Array    (withArrayLen)
@@ -162,7 +161,7 @@
      if      mimeTarget == unsafeIndex mimesPriorities 0 then PNG selContent
      else if mimeTarget == unsafeIndex mimesPriorities 1 then JPEG selContent
      else if mimeTarget == unsafeIndex mimesPriorities 2 then BITMAP selContent
-     else UTF8 (T.strip $ toS selContent)
+     else UTF8 $ toS selContent
 
    -- getContentIncrementally acc = do
    --   _ <- xDeleteProperty display ownWindow selectionTarget
diff --git a/src/Main.hs b/src/Main.hs
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -40,6 +40,7 @@
   , imageCachePath             :: Text
   , usePrimarySelectionAsInput :: Bool
   , blacklistedApps            :: [Text]
+  , trimSpaceFromSelection     :: Bool
   } deriving (Show, Read)
 
 type ClipHistory = Vector Clip.Selection
@@ -76,13 +77,15 @@
 
 
 appendToHistory :: (MonadIO m, MonadReader Config m) => Clip.Selection -> ClipHistory -> m (ClipHistory, ClipHistory)
-appendToHistory sel history' =
+appendToHistory sel history' = do
+  trimSelection <- view $ to trimSpaceFromSelection
   case sel of
-    Clip.Selection _ (Clip.UTF8 _) -> appendGeneric sel history'
+    Clip.Selection appName (Clip.UTF8 txt) -> appendGeneric (if trimSelection then Clip.Selection appName (Clip.UTF8 (T.strip txt)) else sel) history'
     Clip.Selection _ (Clip.PNG bytes) -> appendImage Clip.PNG ".png" bytes
     Clip.Selection _ (Clip.JPEG bytes) -> appendImage Clip.JPEG ".jpeg" bytes
     Clip.Selection _ (Clip.BITMAP bytes) -> appendImage Clip.BITMAP ".bmp" bytes
 
+
   where
     appendImage imgCtr extension bytes = do
       cachePth <- view (to imageCachePath)
@@ -217,11 +220,20 @@
   let cfgPath = home <> "/.config/greenclip.cfg"
 
   cfgStr <- readFile cfgPath `catchAll` const mempty
-  let unprettyCfg = cfgStr & T.strip . T.replace "\n" "" . toS
-  let cfg = fromMaybe defaultConfig (readMaybe $ toS unprettyCfg)
-  let prettyCfg = show cfg & T.replace "," ",\n" . T.replace "{" "{\n " . T.replace "}" "\n}"
-  writeFile cfgPath prettyCfg
 
+  let unprettyCfg' = cfgStr & T.strip . T.replace "\n" "" . toS
+  let unprettyCfg = if "trimSpaceFromSelection" `T.isInfixOf` unprettyCfg'
+                      then unprettyCfg'
+                      else T.replace "}" ", trimSpaceFromSelection = True }" unprettyCfg'
+  let cfgMaybe = readMaybe $ toS unprettyCfg
+  let cfg = fromMaybe defaultConfig cfgMaybe
+
+  -- Write back the config file if the current one was invalid
+  _ <- if isNothing cfgMaybe || unprettyCfg /= unprettyCfg'
+        then let prettyCfg = show cfg & T.replace "," ",\n" . T.replace "{" "{\n " . T.replace "}" "\n}"
+             in writeFile cfgPath prettyCfg
+        else return ()
+
   historyPath' <- expandHomeDir $ cfg ^. to historyPath
   staticHistoryPath' <- expandHomeDir $ cfg ^. to staticHistoryPath
   imageCachePath' <- expandHomeDir $ cfg ^. to imageCachePath
@@ -232,7 +244,7 @@
                }
 
   where
-    defaultConfig = Config 50 "~/.cache/greenclip.history" "~/.cache/greenclip.staticHistory" "/tmp/" False []
+    defaultConfig = Config 50 "~/.cache/greenclip.history" "~/.cache/greenclip.staticHistory" "/tmp/" False [] True
     expandHomeDir str = (toS . fromMaybe (toS str) . listToMaybe <$> wordexp (toS str)) `catchAll` (\_ -> return $ toS str)
 
 
@@ -253,7 +265,7 @@
     -- Should rename COPY into ADVERTISE but as greenclip is already used I don't want to break configs
     -- of other people
     COPY sel -> runReaderT (advertiseSelection sel) cfg
-    HELP     -> putText $ "greenclip v3.1 -- Recyle your clipboard selections\n\n" <>
+    HELP     -> putText $ "greenclip v3.2 -- Recyle your clipboard selections\n\n" <>
                           "Available commands\n" <>
                           "daemon: Spawn the daemon that will listen to selections\n" <>
                           "print:  Display all selections history\n" <>
