Home Interests Vim

Vim: Convert Tabs to Spaces

howchoo
howchoo   (467)
August 25, 2023
2 minutes

Share

Interests
Posted in these interests:

Vim

vim • 5 guides

Tabs are evil. This guide will show you how to convert tabs to spaces in Vim.

1 – Use expand tab to convert new tabs to spaces

The expandtab property will ensure that when you hit tab it will actually use spaces. So first set the number of spaces a tab should be, then set expandtab.

set tabstop=2 shiftwidth=2 expandtab

Tabstop determines how many columns a tab counts for. Shiftwidth determines how many columns text is indented when using reindent operations. Expandtab is what actually uses spaces instead of tabs.

2 – Convert existing tabs to spaces

If you’ve got a file already full of tabs, converting to spaces is super easy. Make sure to follow step one first, then use retab.

Open the file and type:

:retab

This will fix all existing tabs.

NEXT UP

How to Change or Switch the Case of Characters in Vim

howchoo
howchoo   (467)
September 18, 2023

Need to change the case of characters to all caps or all lowercase? This is easily done using Vim. This guide will show you how to change the case of characters in Vim. tl;dr Toggle “Hello” to “hELLO” with g~. Uppercase “Hello” to “HELLO” with gU. Lowercase “Hello” to “hello” with gu. 1 – Select the text you’re

Continue Reading

howchoo

 467 guides

Introducing Howchoo, an enigmatic author whose unique pen name reflects their boundless curiosity and limitless creativity. Mysterious and multifaceted, Howchoo has emerged as a captivating storyteller, leaving readers mesmerized by the uncharted realms they craft with their words. With an insatiable appetite for knowledge and a love for exploration, Howchoo's writing transcends conventional genres, blurring the lines between fantasy, science fiction, and the surreal. Their narratives are a kaleidoscope of ideas, weaving together intricate plots, unforgettable characters, and thought-provoking themes that challenge the boundaries of imagination.

Discover interesting things!

Explore Howchoo's most popular interests.

Explore