复制粘贴时,Vim会缩进每行代码

时间:2016-12-12 16:23:43

标签: vim indentation

当我复制并浏览Vim中的一段代码时,每一行都缩进一行。例如,我有这个来源:

    print "Hello"
    print "World"
    print "I'm copying"
    print "and pasting"

粘贴到Vim时会混乱:

print "Hello"
        print "World"
            print "I'm copying"
                print "and pasting"

为了复制长行代码,它非常令人沮丧,因为一切都不对齐(对python不好)。

这是我的vimrc。它目前在换行符上自动缩进,并用标准的4个空格替换制表符。

filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab

虽然这个配置有效但是有些东西导致了复制粘贴问题。如何解决这个问题,但仍保留我定义的行为?

1 个答案:

答案 0 :(得分:7)

使用+(bool)CheckValuesInKeyChainWithUsername:(NSString*)username { NSDictionary* dictSearch = [NSDictionary dictionaryWithObjectsAndKeys:(__bridge id)(kSecClassInternetPassword), kSecClass, kCFBooleanTrue, kSecReturnAttributes, kCFBooleanTrue, kSecReturnData, nil]; NSDictionary* found = nil; CFDictionaryRef foundCF; OSStatus errOS = SecItemCopyMatching((__bridge CFDictionaryRef) dictSearch, (CFTypeRef*)&foundCF); NSLog(@"%d",(int)errOS); found = (__bridge NSDictionary*)(foundCF); if (!found) { return false; } return true; } +(void)SaveUsername:(NSString*)user withPassword:(NSString*)pass { // Create dictionary of parameters to add NSData* passwordData = [pass dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary* dict = [NSDictionary dictionaryWithObjectsAndKeys:(__bridge id)(kSecClassInternetPassword), kSecClass, passwordData, kSecValueData, user, kSecAttrAccount, nil]; // Try to save to keychain OSStatus errOS = SecItemAdd((__bridge CFDictionaryRef) dict, NULL); NSLog(@"Error Code: %d", (int)errOS); } 切换到粘贴模式。

This article explains paste mode

它专门用于将文本粘贴到vim中,因此它不会触发任何输入映射。完成后,请记住:set paste以恢复映射。