Skip to content

Use softtabstop instead of tabstop. #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 7, 2017
Merged

Use softtabstop instead of tabstop. #228

merged 2 commits into from
Jun 7, 2017

Conversation

ryanpcmcquen
Copy link
Contributor

Closes #223.

@begriffs
Copy link
Owner

Looking at these docs it seems like tabstop and softtabstop are complementary to one another, not mutually exclusive. http://tedlogan.com/techblog3.html

Can you explain the specific formatting problem you're having that motivates this pull request?

@ryanpcmcquen
Copy link
Contributor Author

ryanpcmcquen commented Feb 12, 2017

Is the intention to always insert 2 spaces? If so, softtabstop should be used. If we want to be dynamic based on the file, then tabstop is better. I ended up putting a lot of tabs in files where I meant to insert spaces because I had tabstop and softtabstop set.

Even that link shows not using tabstop if you intend to use spaces.

@begriffs
Copy link
Owner

begriffs commented Jun 4, 2017

Sorry I've been procrastinating making a decision about this. Let's think through all the tab settings.

Set tabstop to tell vim how many columns a tab counts for. ... This is the only command here that will affect how existing text displays.

This setting affects the display of actual tab characters in a file, so is not even relevant for files with all spaces. However we could set it to 2 just in case we're reading a file that another editor saved which has tabs.

When expandtab is set, hitting Tab in insert mode will produce the appropriate number of spaces.

I used to use real tabs for my code, and then started doing Ruby programming where everybody uses only spaces, at which point I switched my style to spaces. I think tabs do make logical sense, but spaces are more common in Haskell so let's enable expandtab.

Set shiftwidth to control how many columns text is indented with the reindent operations (<< and >>)

Choose 2 to match the tabstop.

Set softtabstop to control how many columns vim uses when you hit Tab in insert mode.

Using the value 2 is consistent with what we want.

Smarttabs ... ensures that tabs are only used for indentation, while spaces are used everywhere else. When you press Tab in insert mode, a tab is inserted when indenting, and/or the correct number of spaces when aligning text .

Since we're always expanding tabs, this setting can be turned off.

Do you want to make these changes in your PR?

Signed-off-by: Ryan Terra <ryan.mcquen@Terra>
@begriffs
Copy link
Owner

begriffs commented Jun 7, 2017

Thank you! Appreciate your nudging me to learn more about how tabs work in vim so we can make this configuration work smoothly for everyone.

@begriffs begriffs merged commit baf3c8c into begriffs:master Jun 7, 2017
@ryanpcmcquen
Copy link
Contributor Author

You are welcome! This really is confusing in Vim, haha.

@ryanpcmcquen
Copy link
Contributor Author

@begriffs how do you feel about changing Ctrl + T to insert a tab in insert mode?

"" Allow the user to insert an actual tab with:
""   Ctrl + T
inoremap <C-T> <C-V><Tab>

Its current behavior is the same as the Tab key.

@begriffs
Copy link
Owner

begriffs commented Jun 8, 2017

This might conflict with the standard keys. In :help ins-special-keys it says,

CTRL-T		Insert one shiftwidth of indent at the start of the current
		line.  The indent is always rounded to a 'shiftwidth' (this is
		vi compatible).  {Vi: only when in indent}

Maybe this is something you could add to your ~/.config/haskell-vim-now/vimrc.local?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants