TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

4 点作者 thatmiddleway将近 12 年前

2 条评论

johncoltrane将近 12 年前
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>
daturkel将近 12 年前
This is potentially very nice for CSS. Thanks for sharing!