Difference between revisions of "Vim"

From wiki
Jump to navigation Jump to search
(Created page with "basic .vimrc set backspace=indent,eol,start set ai set si set hlsearch syntax enable set ruler")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
basic .vimrc
basic .vimrc
set backspace=indent,eol,start
set backspace=indent,eol,start
set ai
set ai
set si
set si
set hlsearch
set hlsearch
syntax enable
syntax enable
set ruler
set ruler
 
 
<pre>
delete blank lines
:g/^$/d
:g will execute a command on lines which match a regex. The regex is 'blank line' and the command is :d (delete)
 
 
fix indent in file
gg=G
=, the indent command can take motions. So, gg to get the start of the file, = to indent, G to the end of the file, gg=G.
</pre>
 
 
Good .rc file
 
git clone git://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_basic_vimrc.sh
 
Pasting protip
 
: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 again.
:set nopaste

Latest revision as of 10:46, 3 October 2016

basic .vimrc

set backspace=indent,eol,start
set ai
set si
set hlsearch
syntax enable
set ruler


delete blank lines
:g/^$/d
:g will execute a command on lines which match a regex. The regex is 'blank line' and the command is :d (delete)


fix indent in file
gg=G
=, the indent command can take motions. So, gg to get the start of the file, = to indent, G to the end of the file, gg=G.


Good .rc file

git clone git://github.com/amix/vimrc.git ~/.vim_runtime
sh ~/.vim_runtime/install_basic_vimrc.sh

Pasting protip

: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 again.

:set nopaste