2 ms·
[code folding section deleted, I stand corrected] Vim's indentation changes still require a mode change three obscure keys and an enter, and vim's discoverabil
by nailer 17y ago
[code folding section deleted, I stand corrected]
Vim's indentation changes still require a mode change three obscure keys and an enter, and vim's discoverability still sucks.
- novas0x2a 17y agoWhat do you mean "yet"? vim has had code folding for years: :help fold.txt If you want to indent code, < and > are your friends. (Really? Indenting code with search/replace? What are we, barbarians?)
- gfodor 17y agoDepending on the area you want to indent, you can use visual mode with % to select the block and then >> it over, or, for more specific regions, use visual block mode with ctrl-V to highlight the first column of the text you want to indent, hit I, indent the line by hitting space, and hit escape. When you move the cursor the other lines will indent.
- Avshalom 17y agoAt least for curly bracket languages. >iB indents the block <iB deindents dunno which languages it works for otherwise http://vim.wikia.com/wiki/Category:Indenting http://vim.wikia.com/wiki/Category:Indenting
- philwelch 17y ago">" is the indent command. Repeat it ">>" to indent the current line. Use any other vim ranging construct (e.g. ">2j") to indent wider ranges--i.e. the current line plus two lines below. "=" is the autoindent command. Vim recognizes many languages and you can give it plugins to understand more. Use "==" to autoindent the current line. My personal favorite, "gg=G", jumps to the top of the document and autoindents the entire thing. One time at work I was gently reminded how many spaces I was supposed to indent per the company's coding standard. I quickly set the relevant editor parameters and with four keystrokes my code was compliant. I think there's a code-folding ability but I've never used it.
- billybob 17y agoIndenting? Heck yes. '=' will indent for you. You just have to give it a movement. =j means 'indent this line and the next' =% means 'indent to the matching brace' =/foo mean 'indent to the next occurrence of foo' 1G=G means 'go to the first line and indent until the last one' If you want specific rules for indenting file types, you can put stuff in your .vim/indent/ folder to define them
- sophacles 17y agoHave you ever tried reading the manual? Seriously, the level of the documentation is pretty good for a free piece of software. Edit: actually, its pretty good for any piece of software.
- pyre 17y agoThe problem comes when you don't know what the topic you're looking for is called in vim. I've only had that problem once or twice over the years, but it can be frustrating (esp. w/ no Internet connection).
- sophacles 17y agoI agree. Fortunately however, :he has tab completion, which certainly reduces such. Also :he index is nice. And for those times with internet, #vim on freenode usually knows the correct :he keyword in seconds.