nalaurethsulfate
nalaurethsulfate

Reputation: 43

Infuriating Tab problem in Vim, in literate Haskell

I am using "Bird" style literate haskell, which requires all code to be like the following:

> module Main (main) where

and if I have a block it should look something like this:

> main = do
>     args = getArgs
>     file = args!![0]

etc. However when I enter the gt sign, then a space and hit tab it tabs over only two spaces!

I have done the following to try to fix the problem:

set tabexpand
set tabstop=4
set softtabstop=4
set noautoindent
set shiftwidth=4

Any help would be much appreciated I thought the above would essentially just make it insert 4 spaces rather than any tabs.

Upvotes: 4

Views: 888

Answers (3)

hammar
hammar

Reputation: 139840

I don't know any easy way to solve this, but here are some workarounds you can try (in rough order of complexity).

  1. Set your indentation to two spaces and live with having to press tab twice.

  2. Make tab indiscriminately insert 4 spaces in insert mode, ignoring all tab stop and indentation rules/options.

    :imap <Tab> <Space><Space><Space><Space> 
    
  3. Use a patched Vim which allows you to set arbitrary tabstops. There's a variable tabstops patch at the Vim patches page.

  4. Write your own indentation algorithm. See :help indentexpr for details on how to do this.

Upvotes: 1

Bastian
Bastian

Reputation: 1

Sure, Vim moves the cursor to col 4 where the next tabstop is located. Don't know if there is a way to set the first tabstop to col 6 (or 2) instead.

Upvotes: 0

Eric Fortis
Eric Fortis

Reputation: 17350

set shiftwidth=4

'shiftwidth' 'sw'   number  (default 8)
            local to buffer
    Number of spaces to use for each step of (auto)indent.  

Upvotes: 1

Related Questions