<p>When running a vim instance in gnu screen hitting shift enter in insert mode adds an 'M' and then a newline, rather than just a newline.</p>

<p>Does anybody know what the problem might be, or where to look?</p>

<p>Relevant system info:</p>

<blockquote>
  <p>Ubuntu 8.04.1</p>
  
  <p>Screen version 4.00.03 (FAU) 23-Oct-06</p>
  
  <p>VIM - Vi IMproved 7.1 (2007 May 12, compiled Jan 31 2008 12:20:21)
    Included patches: 1-138</p>
  
  <p>Konsole 1.6.6 (Using KDE 3.5.10)</p>
</blockquote>

<p>Thanks to the comments.  When checking the value of <code>$TERM</code> I noticed that it was <code>xterm</code> (as expected), but within screen <code>$TERM</code> was set to <code>screen-bce</code>.  Setting <code>TERM=xterm</code> after launching screen resolves this issue.</p>

<p>Adding the following to <code>~/.screenrc</code> solved the problem without having to do anything manually:</p>

<blockquote>
  <p>term xterm</p>
</blockquote>

[{'answer_id': 63416, 'author': 'tzot', 'author_id': 6899, 'author_profile': 'https://Stackoverflow.com/users/6899', 'pm_score': 3, 'selected': True, 'text': '<p>Missing info from your question:</p>\n\n<ol>\n<li>Where do you run screen and see this issue? Some terminal app (KTerminal, Gnome terminal, virtual console etc) or remote session (eg putty, ssh from another computer)</li>\n<li>do a “echo $TERM” and tell us its output</li>\n<li>do a “cat -v”, press Shift-Enter, then Enter, then <kbd>Ctrl</kbd>-<kbd>D</kbd> and then tell us what is output.</li>\n</ol>\n'}, {'answer_id': 928171, 'author': 'graywh', 'author_id': 18038, 'author_profile': 'https://Stackoverflow.com/users/18038', 'pm_score': 0, 'selected': False, 'text': '<p>First, you could fix your $TERM for within konsole.  Install "ncurses-term" and configure konsole to set $TERM=konsole-256color.  Then configure screen with "term screen-256color".  Or \'konsole\' and \'screen\', respectively, if that\'s your preference.  Konsole and screen are <em>not</em> xterm and doesn\'t support everything xterm does, so using incorrect $TERM can lead to bad things.</p>\n'}]
['https://Stackoverflow.com/questions/63378', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/7538/']