VI commands: Difference between revisions
New page: VI SHIT VIM defaults are in ~/.vimrc :set noai Sets auto indent :set nocindent sets autoindenting for braces and stuff (good to put these off for pasting stuff from other config file... |
No edit summary |
||
Line 10: | Line 10: | ||
sets autoindenting for braces and stuff | sets autoindenting for braces and stuff | ||
:set paste | |||
is good to paste stuff in the format it was copied | |||
(good to put these off for pasting stuff from other config files) | (good to put these off for pasting stuff from other config files) |
Revision as of 08:16, 24 September 2009
VI SHIT
VIM defaults are in ~/.vimrc
- set noai
Sets auto indent
- set nocindent
sets autoindenting for braces and stuff
- set paste
is good to paste stuff in the format it was copied
(good to put these off for pasting stuff from other config files)
<shift+v> visual line select <alt+v> visual select point to point <ctrl+b> visual block select Y = yank (copy) d = (cut) P = paste after
- start-line,end-linew /tmp/filename
write lines to /tmp/filename
- .,$s/bla/BLA/g
replace bla to BLA from current line to last line in doc.
lines: . = current line, $ = last line
- .,100 d = delete from current line to line 100 (, = seperator)
in the editor, doing 226dd will delete the next 226 lines from the cursor
- !ls
runs 'ls'
- r!ls
runs ls and puts the output in the open buffer
- set number
- set nonumber
puts the line numbering on or off
- set textwidth=0
puts the max textwidth off for wrapping
Find and replace goes with
- %s/findme/replaceme/
for the first instance and
- %s/findme/replaceme/g
for every instance in the file (g) The / charachter can be replaced with any other character and special characters such as /,",', etc can be escaped. EG to replace every / in a file with a new line use
- %s/\//\r/g
To get rid of "^M" (MSDOS carriage returns) in a file or to put them in
press control+V and then type M.
You can find and replace with this too.
Some usefull regular expressions to know (and use in replacements) are \n - newline \r - return use only \r to get stuff onto next lines, \n creates the ^@ char, and I'm not sure what that does yet