diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index edd3f39..2aa49e8 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -1083,6 +1083,8 @@ void expr_print(struct expr *e, void (*fn)(void
*, struct symbol *, const char *
Â  Â  Â  Â }
Â  Â  Â  Â if (expr_compare_type(prevtoken, e->type) > 0)
Â  Â  Â  Â  Â  Â  Â  Â fn(data, NULL, ")");
+
+ Â  Â  Â  str_screen_wrap(data, "||");
Â }

Â static void expr_print_file_helper(void *data, struct symbol *sym,
const char *str)
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index f379b0b..8fc69a3 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -112,6 +112,7 @@ struct gstr str_assign(const char *s);
Â void str_free(struct gstr *gs);
Â void str_append(struct gstr *gs, const char *s);
Â void str_printf(struct gstr *gs, const char *fmt, ...);
+void str_screen_wrap(struct gstr *gs, const char *break_point);
Â const char *str_get(struct gstr *gs);

Â /* symbol.c */
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index b6b2a46..f6c8930 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -7,6 +7,7 @@

Â #include <string.h>
Â #include "lkc.h"
+#include <curses.h>

Â /* file already present in list? If not add it */
Â struct file *file_lookup(const char *name)
@@ -131,3 +132,54 @@ const char *str_get(struct gstr *gs)
Â  Â  Â  Â return gs->s;
Â }

+static const char string_breaker[] = { '\\', '\n' };
+#define STRING_BREAKER_SIZE sizeof(string_breaker)
+/*
+ * wrap long lines in the passed in strings. The lines are wrapped to fit into
+ * the current screen width. The lines can be broken only at 'break points' -
+ * passed in as the second parameter. A \<cr> (two characters) sequence is
+ * instered after the appropriate break points to get the line wrapped to fit
+ * the screen.
+*/
+void str_screen_wrap(struct gstr *data, const char *break_point)
+{
+ Â  Â  Â  char *eol_location;
+ Â  Â  Â  int total_length;
+ Â  Â  Â  int screen_width = getmaxx(stdscr) - 10;
+ Â  Â  Â  int break_point_size = strlen(break_point);
+
+ Â  Â  Â  eol_location = strrchr(data->s, '\n');
+ Â  Â  Â  if (!eol_location)
+ Â  Â  Â  Â  Â  Â  Â  eol_location = data->s;
+
+ Â  Â  Â  total_length = strlen(data->s) + 1; /* include trailing zero */
+
+ Â  Â  Â  /* while last line's length exceeds screen width */
+ Â  Â  Â  while ((total_length - (eol_location - data->s) - 1) > screen_width) {
+ Â  Â  Â  Â  Â  Â  Â  char *prev_breakp;
+ Â  Â  Â  Â  Â  Â  Â  char *breakp = eol_location;
+ Â  Â  Â  Â  Â  Â  Â  do {
+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  prev_breakp = breakp;
+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  breakp = strstr(breakp + 1, break_point);
+ Â  Â  Â  Â  Â  Â  Â  } while (breakp &&
+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â ((breakp - eol_location) < screen_width));
+
+ Â  Â  Â  Â  Â  Â  Â  if (prev_breakp == eol_location) {
+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  /* no break_points found */
+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  return;
+ Â  Â  Â  Â  Â  Â  Â  }
+
+ Â  Â  Â  Â  Â  Â  Â  total_length += STRING_BREAKER_SIZE;
+ Â  Â  Â  Â  Â  Â  Â  if (data->len < total_length) {
+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  data->s = realloc(data->s, total_length);
+ Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  Â  data->len = total_length;
+ Â  Â  Â  Â  Â  Â  Â  }
+ Â  Â  Â  Â  Â  Â  Â  prev_breakp += break_point_size;
+
+ Â  Â  Â  Â  Â  Â  Â  eol_location = prev_breakp + STRING_BREAKER_SIZE;
+ Â  Â  Â  Â  Â  Â  Â  /* move the remainder of the string including trailing zero */
+ Â  Â  Â  Â  Â  Â  Â  memmove(eol_location, prev_breakp, strlen(prev_breakp) + 1);
+ Â  Â  Â  Â  Â  Â  Â  /* insert the line break */
+ Â  Â  Â  Â  Â  Â  Â  memcpy(prev_breakp, string_breaker, STRING_BREAKER_SIZE);
+ Â  Â  Â  }
+}
