Posts Tagged ‘Tips’
Screen Tips & Tricks
Screen is a program which enables users to create more system shells without the need of logging in multiple times. And it allows to leave programs running after you’ve logged out
Configure
$ cat ~/.screenrc
hardstatus alwayslastline
hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}'
caption always
caption string "%{= .W}%-Lw%{=b .y}[%50>%n%f*%t]%{-}%+Lw%< %{=b .y}/%{-} %Y/%m/%d %c:%s %D %l"
Running screen
Detach screen: C-a d
Resume screen: screen -r
Get help: C-a ?
Windows
Create a new window: C-a c
switch to window 0: C-a 0
…
switch to window 9: C-a 9
Regions
Split current region: C-a S
Switch to next region: C-a tab
Scrollback Mode and Navigation
Enter scrollback mode: C-a [
VIM TIPs
Move around quickly
/pattern - find the text.
* - find word under the cursor.
% - jump to it’s matching.
[{ - jump back to the start of the current code block.
gd - jump from the use of a variable to its local declaration.
CTRL-] : Jump to tag under cursor
Optoins:
set incsearch - increase search
set hlsearch - highlight all matches
Don’t type it twice
:s/pattern/string/ - substitute.
* cw n .
m{a-z} - set mark {a-z} at current position
‘{a-z} - Jump to the mark {a-z}
CTRL-N - expand word.
q{a-z} - Record typed characters into register {a-z}.
q - Stops recording.
@{a-z} - Execute the regiser {a-z}.
Fix it when it’s wrong
abbr lhs rhs
Setting and Configuration
:options - view and set options
:set - show all modified options
:let - list the values of all variables
Text Object
aw, aW - ambient word or WORD (see docs)
iw, iW - inner word or WORD (see docs)
as, is - ambient or inner sentence
ap, ip - ambient or inner paragraph
a{, i{ - whole { .. } block or text inside it
a(, i( - whole ( .. ) block or just text inside it
a<, i< - whole < .. > block or just text inside it
a’, i’ - single-quoted string or just the text inside
a”, i” - double-quoted string or just the text inside
at, it - whole tag block or just text inside (HTML and XML tags)
das - delete the sentence, including whitespace after
ci( - change text inside (..) block
yat - copy the entire closest tag block the cursor is
inside
gUi’ - uppercase text inside the single-quoted string
vip - select the paragraph in Visual mode, without whitespace after
Spellcheck
z= see suggestions
zg add a word to the dictionary
zug undo an addition to the dictionary
]s move to the next misspelled word
[s move to the previous one
Code Browser
:he C-editing
:ts : List the tags that match.
CTRL-T : Jump back to before a CTRL-]
gf : Go to file name under the cursor
Code completion
CTRL-P
Ctrl-x Ctrl-o
CTRL-X CTRL-] : Completing tags
CTRL-X CTRL-P
NERD tree
o - open/close folder, open file
Others
remove ^M: %s/r//
find next lines contains more than 80 characters: /\%81c
remove lines which contains more than 80 characters: :g/%81c/d
gf - go to file under cursor
“+y - copy to gui-clipboard
“+p - paste from gui-clipboard
[I and ]I - list lines with word under the cursor
]p, ]P - paste after/before but adjust the indent
Insert a ‘(’ character at the begin of every lines:
:%s/^/(/
PageDown: CTRL-F
PageUp: CTRL-B
Extracting a vimball:
:vim filename.vba
:so %
Convert code to html:
:TOhtml