在Vim中向左或向右移动光标时,防止光标下的打开折叠

时间:2018-03-19 07:48:22

标签: vim move fold

每当我使用h或l向左或向右移动光标时,光标下方的折叠会自动打开。顺便说一句,向上或向下移动没有这个问题。有什么办法可以防止水平移动时自动打开折叠?

2 个答案:

答案 0 :(得分:3)

您可以创建自动命令:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/background_light"
    android:fitsSystemWindows="true"
    >

    <android.support.design.widget.AppBarLayout
        android:id="@+id/main.appbar"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:fitsSystemWindows="true"
        >

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/main.collapsing"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleMarginStart="48dp"
            app:expandedTitleMarginEnd="64dp"
            >

            <ImageView
                android:id="@+id/main.backdrop"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="centerCrop"
                android:fitsSystemWindows="true"
                android:src="@drawable/office_back"
                app:layout_collapseMode="parallax"
                />

        </android.support.design.widget.CollapsingToolbarLayout>


    </android.support.design.widget.AppBarLayout>


    <android.support.v7.widget.CardView
        android:layout_margin="2dp"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        app:cardCornerRadius="8dp"

        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <android.support.v4.view.ViewPager
            android:id="@+id/newOrder_viewPager"
            android:padding="16dp"
            android:layout_width="match_parent"
            android:layout_height="match_parent"/>

    </android.support.v7.widget.CardView>


</android.support.design.widget.CoordinatorLayout>

如果当前行已展开,则autocmd! CursorMoved * if foldclosed('.') != -1 | \ nnoremap h <nop>| \ nnoremap l <nop>| \ else | \ silent! unmap h| \ silent! unmap l| \ endif 会返回foldclosed('.')。而不是使用此自动命令,只需避免按-1h折叠。

答案 1 :(得分:0)

:help 'foldopen'的默认值包含hor;这会导致水平移动(如lh)打开折叠。

要禁用此功能,只需将其添加到您的~/.vimrc

set foldopen-=hor