Pimp vim for coding

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
^rooker
Site Admin
Posts: 1469
Joined: Fri Aug 29, 2003 8:39 pm

Pimp vim for coding

Post by ^rooker »

Here are a few tips for configuring VIM to be more comfortable for programmer's needs.

1) Changes within "/etc/vim/vimrc":

*) tab-free indent with reasonable width:

Code: Select all

" Make it comfortable for coding and editing config files:
set shiftwidth=4
set tabstop=4
set expandtab
set tabpagemax=20
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
User avatar
^rooker
Site Admin
Posts: 1469
Joined: Fri Aug 29, 2003 8:39 pm

Different settings. Temporary.

Post by ^rooker »

If you happen to contribute to, or edit code from someone else, who has different indentation width, here's a one-liner for adjusting vim's settings temporarily for all opened tabs.
For example, if you want to indent only 2 characters (instead of the globally configured "4"), you can type:

Code: Select all

:tabdo set shiftwidth=2 || set tabstop=2 || set expandtab
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
User avatar
peter_b
Chatterbox
Posts: 338
Joined: Tue Nov 12, 2013 2:05 am

Syntax highligh: Markdown instead of Modula2

Post by peter_b »

By default, many vim installations assume ".md" files to be "Modula2" sourcecode instead of Markdown.
Add this line to your /etc/vim/vimrc (or the one in your user's home) to change that:

Code: Select all

" Markdown syntax (instead of modula2):
autocmd BufNewFile,BufRead *.md set filetype=markdown
:D
User avatar
peter_b
Chatterbox
Posts: 338
Joined: Tue Nov 12, 2013 2:05 am

Re: Pimp vim for coding

Post by peter_b »

Simply copy/paste/save the following to "/etc/vim/vimrc.local":
(Attached is a copy of that configfile ready-to-use. Just remove the ".txt" (forum security rules))

Code: Select all

" Generally useful:
syntax on
set background=dark
set ignorecase     " Do case insensitive matching
set mouse=
set ttymouse=

" Make it comfortable for coding and editing config files:
set shiftwidth=4
set tabstop=4
set expandtab
set tabpagemax=20
Attachments
vimrc.local.txt
Nice generic VIM config to use when often editing config files or source code or XML.
(345 Bytes) Downloaded 37 times
Post Reply