Vim Hints

From Wiki
Jump to navigationJump to search
vi $(grep -l xxx *.c) to edit a list of files from grep
 
:syntax off     Turns off syntax coloring 
:set ai         Turns on autoindent (turn off when pasting) 
:set ts=4       Sets tab stops to 4, 8, etc 
:set nolist     Hides tab coloration 
:set expandtab  Expands tabs into spaces 
:set number     Turn on line numbers 
:set keywordprg=info\ libc\ \"Function\ Index\" 
:set ve=all     Virtual editing (no jumping around with nowrap) 
 
gqip            Reflow a paragraph of text 
gq`a            Reflow to marker A 

zo              Open a fold
zc              Close a fold
zR              Set foldlevel to deepest value (seems to open all folds recursively)
zf<motion>      Create a fold (zf% at opening or closing brace to fold a function)

[c              Jump backwards to the previous start of a change
]c              Jump forwards to the next start of a change 
do              Get changes from other window into the current window
dp              Put the changes from current window into the other window
:diffupdate     Update differences

:g/<pattern>/d  Delete all lines matching pattern
:v/<pattern>/d  Delete all lines NOT matching pattern

:help i_^x      Help on Ctrl-x in insert mode
 
Add trailing spaces, join all lines not starting with *, replace any CR or LF combination with LF, and delete any line not starting with *SIGNAL

:%s/$/ /g | %s/\n\([^\*]\)/\1/g | %s#\s*\r\?$## | g!/^\*SIGNAL\*/d 
:wq 
 

    Input 

*SIGNAL* LM_CLK 
U1.Y12 R26.1 
*SIGNAL* LCD_V_CON 
TP30.1 R48.2 
*SIGNAL* LCD_VCC 
J2.2 R11.1 
R11.1 J5.1 
J5.1 J5.24 
J5.24 U6.24 
U6.24 U7.24 
U7.24 U8.24 
U8.24 J7.29 
J7.29 J7.30 
*SIGNAL* LCD_UP_DOWN 
Q4.1 J6.18 
*SIGNAL* LCD_RIGHT_LEFT 
J6.16 U6.6 
*SIGNAL* LCD_ENABLE 
R3.2 U1.C12 
U1.C12 U6.7 
 

    Output 

 
*SIGNAL* LM_CLK U1.Y12 R26.1 
*SIGNAL* LCD_V_CON TP30.1 R48.2 
*SIGNAL* LCD_VCC J2.2 R11.1 R11.1 J5.1 J5.1 J5.24 J5.24 U6.24 U6.24 U7.24 U7.24 U8.24 U8.24 J7.29 J7.29 J7.30 
*SIGNAL* LCD_UP_DOWN Q4.1 J6.18 
*SIGNAL* LCD_RIGHT_LEFT J6.16 U6.6 
*SIGNAL* LCD_ENABLE R3.2 U1.C12 U1.C12 U6.7