Why does Vim save files with a ~ extension?

I think the better solution is to place these lines in your vimrc file set backupdir=~/vimtmp//,. set directory=~/vimtmp//,. The first line is for backup files, the second line for swap files. The double slash at the end ensures that there is no conflict in case of two files having the same name, see comments (at … Read more

How to convert the ^M linebreak to ‘normal’ linebreak in a file opened in vim?

Command :%s/<Ctrl-V><Ctrl-M>/\r/g Where <Ctrl-V><Ctrl-M> means type Ctrl+V then Ctrl+M. Explanation :%s substitute, % = all lines <Ctrl-V><Ctrl-M> ^M characters (the Ctrl-V is a Vim way of writing the Ctrl ^ character and Ctrl-M writes the M after the regular expression, resulting to ^M special character) /\r/ with new line (\r) g And do it globally … Read more

Turning off auto indent when pasting text into vim

Update: Better answer here: https://stackoverflow.com/a/38258720/62202 To turn off autoindent when you paste code, there’s a special “paste” mode. Type :set paste Then paste your code. Note that the text in the tooltip now says — INSERT (paste) –. After you pasted your code, turn off the paste-mode, so that auto-indenting when you type works correctly … Read more

Redefine tab as 4 spaces

It depends on what you mean. Do you want actual tab characters in your file to appear 4 spaces wide, or by “tab” do you actually mean an indent, generated by pressing the tab key, which would result in the file literally containing (up to) 4 space characters for each “tab” you type? Depending on … Read more

Why should I use an IDE? [closed]

It really depends on what language you’re using, but in C# and Java I find IDEs beneficial for: Quickly navigating to a type without needing to worry about namespace, project etc Navigating to members by treating them as hyperlinks Autocompletion when you can’t remember the names of all members by heart Automatic code generation Refactoring … Read more

Vim 80 column layout concerns

As of vim 7.3, you can use set colorcolumn=80 (set cc=80 for short). Since earlier versions do not support this, my .vimrc uses instead: if exists(‘+colorcolumn’) set colorcolumn=80 else au BufWinEnter * let w:m2=matchadd(‘ErrorMsg’, ‘\%>80v.\+’, -1) endif See also the online documentation on the colorcolumn option.