Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 423117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:08:54+00:00 2026-05-12T19:08:54+00:00

In Vim, how do I break a line of text with a newline? For

  • 0

In Vim, how do I break a line of text with a newline?

For example, I’m in INSERT mode and I’d like to get from here…

$('#toggle_contact_search_mode').click([CURSOR IS HERE]);

To here…

$('#toggle_contact_search_mode').click(
  [CURSOR IS HERE]
);

The result I’m getting is that when I’m in insert mode and I have the cursor in the first position above and I hit return…

  • Vim goes to normal mode.
  • The line with the cursor scrolls to the bottom of the screen.
  • Code throughout the file is reformatted incorrectly. For example, in another part of the file the code is reformatted like this:

$('.edit_phone_number').ajaxForm({
success: function(response) {
$('input, select, textarea', '.edit_phone_number').removeClass('updating');
}   
});

$('input, select, textarea', '.edit_phone_number').focus(function(event) { 
    $(event.target).removeClass('updating').addClass('focussed');
    });

I don’t want any reformatting at all. I just want Vim to just enter a newline and remain in insert mode.


UPDATE

When I temporarily remove my .vimrc file, the Vim behaves as expected. My .vimrc:

" ==================================================================================
" Global stuff
" ==================================================================================

" Prevent Vim from emulating vi bugs and limitations
:set nocompatible

" Custom status line based on one from here:
" http://www.linux.com/archive/feature/120126
:set statusline=\ \ %f\ \ [FORMAT=%{&ff}]\ \ [TYPE=%Y]\ \ [POS=%04l,%04v][%p%%]\ \ [LEN=%L]

" Set status line colors
highlight StatusLine term=reverse ctermfg=DarkBlue ctermbg=Grey

" Set status line to be shown above the command buffer.
:set laststatus=2

" Enable syntax highlighting
:syntax on

" Enable line numbering, taking up 6 spaces
:set number

" Allow <BkSpc> to delete line breaks, beyond the start of the current
" insertion, and over indentations
" set backspace=eol,start,indent

" ==================================================================================
" Searching
" ==================================================================================

" Highlight matches as you type in the search string
:set incsearch
:set showmatch

" When searching ignore case (except explicit caps)
:set ignorecase
:set smartcase

" ==================================================================================
" Indenting
" ==================================================================================

" Copy indent from current line when starting a new line
" :set autoindent
"
" :set smartindent

" :filetype plugin on

" indent depends on filetype
" :filetype indent on

:set tabstop=2
:set softtabstop=2
:set shiftwidth=2
:set expandtab

" ==================================================================================
" Mappings
" ==================================================================================

" ESC
imap <C-k> <ESC>

" Go to the next tab
nmap <C-j> gt
imap <C-j> <ESC>gt

" Auto indent entire file.
" Sets a mark ("mt""), moves across the whole file to indent it ("gg=G"), 
" then returns to the mark ("'t").
nmap <C-m> mtgg=G't
imap <C-m> <ESC><C-m>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:08:55+00:00Added an answer on May 12, 2026 at 7:08 pm

    Your problem is the imap <C-m> mapping — control-M is logically equivalent to enter on the terminal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is possible to insert a line break where the cursor is in Vim without
How can I break long lines when writing c++ code in vim? For example,
In vim, in normal mode, if the cursor is in a word, not the
In VIM in command line mode a % denotes the current file, cword denotes
If i set the following option in Vim, set textwidth=80 the text will break
When I pop into Vim's visual mode to, for example, indent a block of
When I'm writing a long line of text in vim (such as a paragraph
ViM has this option hlsearch where a searched string is displayed in highlight mode
I am giving Vim xdebug plugin a try, but when I put cursor on
Vim has templates and idioms programming and other similar stuff. For example, the c.vim

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.