TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Vim-c-cr, a super simple plugin to give ctrl+enter a little magic

4 pointsby thatmiddlewayalmost 12 years ago

2 comments

johncoltranealmost 12 years ago
Note that &#60;C-CR&#62; only works in GUI Vim because it is virtually indistinguishable from &#60;CR&#62; in (most?) terminal emulators. They actually send different signals but Vim doesn't care.<p>I've had many slightly dumber variations of that mapping in my ~/.vimrc for a while, using &#60;leader&#62;&#60;CR&#62; instead of &#60;C-CR&#62; for the reason outlined above.<p><i>Edit</i><p>I borrowed you Closer() function and modified it to make it work simply on &#60;CR&#62;, based on my previous mapping:<p><pre><code> " my previous mapping inoremap &#60;leader&#62;&#60;CR&#62; &#60;CR&#62;&#60;C-o&#62;==&#60;C-o&#62;O " your revised function function! Closer() let prevchar = getline(".")[col(".")-2] if prevchar ==# "{" return "\&#60;CR&#62;}\&#60;C-o&#62;==\&#60;C-o&#62;O" elseif prevchar ==# "[" return "\&#60;CR&#62;]\&#60;C-o&#62;==\&#60;C-o&#62;O" elseif prevchar ==# "(" return "\&#60;CR&#62;)\&#60;C-o&#62;==\&#60;C-o&#62;O" else return "\&#60;CR&#62;" endif endfunction " your revised mapping inoremap &#60;expr&#62; &#60;CR&#62; Closer()</code></pre>
daturkelalmost 12 years ago
This is potentially very nice for CSS. Thanks for sharing!