VI commands: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 79: | Line 79: | ||
Some usefull regular expressions to know (and use in replacements) are | Some usefull regular expressions to know (and use in replacements) are | ||
\n - newline | \n - newline (for windows files) | ||
\r - return | \r - return (for unix files) | ||
\s - for spaces | |||
use only \r to get stuff onto next lines, \n creates the ^@ char, and I'm not sure what that does yet | use only \r to get stuff onto next lines, \n creates the ^@ char, and I'm not sure what that does yet | ||
</pre> | </pre> |
Latest revision as of 09:34, 6 October 2017
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) To replace every ; in a file with a new line use :%s/;/<ctrl-v> <enter>(will turn into ^M)/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 (or press the enter key). You can find and replace with this too. Some usefull regular expressions to know (and use in replacements) are \n - newline (for windows files) \r - return (for unix files) \s - for spaces use only \r to get stuff onto next lines, \n creates the ^@ char, and I'm not sure what that does yet