Showing posts with label Emacs. Show all posts
Showing posts with label Emacs. Show all posts

Wednesday, February 06, 2013

Search in emacs with grep

Search pattern in different directories and different files:

M-x grep RETURN
grep -RnisIw --exclude-dir=bin MPEG2DEC ../

-I suppose to ignore binary files, but for some reason I have to add "--exclude-dir"
../ to search all directories from parent directory. Use ./ to search current directory

If only search all .c files:
grep -RnisIw --exclude-dir=bin --include=*.c MPEG2DEC ../

or exclude all .h files:
grep -RnisIw --exclude=*.h MPEG2DEC ../

M-x rgrep works too, but it has less controls.

Thursday, September 10, 2009

Search current word in vi, and some others

Emacs guy has to use vi sometimes. Search word under cursor:
*
# (reverse)
--
0 : move to beginning of the line
$ : -----------end----
f(F): find a character in the line (fa)

some other commands [update: 10/27/09]:

nG : move to line #n, or G to end of the file
:n : move to line #n
:$ : move the end of the file
1G or [[ : move to first line of the file
G or ]] : ----------last-----
n+: move cursor to next n lines
n-: -------------------last-------
u : undo last command

ma: set a mark 'a' here, use 'a to move here later

Friday, October 10, 2008

Friday, December 28, 2007

Emacs: org-mode basic

Basic keys:
TAB, S-TAB hide/show tree
C-c . show date/time. Use S-arrow, S-< > to change. Type 20:01 directly
C-c C-s schedule
C-c C-d deadlin
C-c a show all parameters
C-c a m search tag
C-. switch between files
[/], - [ ] check list, [x] C-c C-c
S-up/down priority A B C

Setup:

(require 'org-install)
(add-to-list '
auto-mode-alist '("\\.org$" . org-mode))
(define-key global-map "\C-cl" '
org-store-link)
(define-key global-map "\C-ca" 'org-agenda)
(setq org-log-done t)
(setq org-agenda-files (list "~/emacs/weisu_org/work.org"
"~/emacs/weisu_org/personal.org"))

Saturday, December 22, 2007

Yahoo! messenger for Emacs

yod
do u really need im in Emacs?

Thursday, December 20, 2007

RegEx basic

  Description Examples
. match any one character .a..
sales1.xls
[ ] define a character set [ns]a[0-9]\.xls
sam.xls
na1.xls
^ anything but [ns]a[0-9]\.xls
sam.xls
na1.xls
\d
\D
\w
\W
any digit, same as [0-9]
any nondigit [^0-9]
same as [a-zA-Z0-9_]
\w\d\w\d\w\d
M1B4F2
90046
H1H2H2
+ match one or more char \w+@\w+\.\w+
Send personal email to ben@forta.com.
* match 0 or more char \w+[\w.]*@[\w.]+\.\w+
Hello .ben@forta.com is my email address.
? match only 0 or 1 char https?://[\w./]+
securely use https://www.forta.com/ instead.
{ } intervals:
{2,4}: min 2, max 4
{3,}: at least 3
\d{1,2}[-\/]\d{1,2}[-\/]\d{2,4}
4/8/03
10-6-2004

2/2/2
\d+: \$\d{3,}\.\d{2}
1001: $496.80 1002: $1290.69 1003: $26.43
*?
+?
{n,}?
Lazy matching
*, +, {n,} are greedy matching
<[Bb]>.*</[Bb]>
living in <B>AK</B> and <B>HI</B>
<[Bb]>.*?</[Bb]>
living in <B>AK</B> and
<B>HI</B>
\b
\B
match the start or end of a word, \bcat\b
The cat scattere
cap\b
captain recap
( ) treat as single entity &nbsp;{2,}
Windows&nbsp;&nbsp;200 (it matches &nbsp;;;;;)
(&nbsp;){2,}
Windows&nbsp;&nbsp;200
(\d{1,3}\.){3}\d{1,3}
Pinging [12.159.46.200]
(19|20)\d{2}
DOB: 1967-08-17
?=
?<=
look ahead
look behind
.+(?=:)
http://www.forta.com/
(?<=\$)[0-9.]+
ABC01: $23.45

Tuesday, November 06, 2007

Emacs Register

C-x r SPC a -- Save location of point in register a, or (C-x / a)
C-x r j a -- Jump to the location saved in register a, or(C-x j a)

C-x r x a -- Copy region into register a, or (C-x x a)
C-x r g a -- Insert text contents of register a, or (C-x g a)

M-x view-register RET a
Display a description of what register

Monday, October 22, 2007

Emacs: some keys in C mode

C-M-a : go to the beginning of the function
C-M-d : go to the end of the function
C-M-p :
C-M-n : { }
C-M-f :
C-M-b : ( )
C-M-u : go to the parent level
C-M-\ : indenting selected region
C-M-h : mark current function?

C-c C-q : indenting current function.

Wednesday, August 22, 2007

Etags

creates tags file: in specified directory, etags -R *
M-x visit-tags-table File
M-. lookfor tags the cursor on
M-, back to original place
C-. open another window and show tags
C-, close tags window
C-M-, search tags, use TAB and mouse mid-button

[update 2/14/2013]
or use following to create table:
 etags `find . -name "*.c" -o -name "*.cpp" -o -name "*.h"`
C-. to locate, and C-* to return

Letter instead of A4 in dvips, xdvi,

The default size of dvips and xdvi is A4. Use texconfig to switch to letter:

texconfig dvips paper letter
texconfig xdvi paper us

Tuesday, July 17, 2007

ansi-term, emacs start and search

M-x ansi-term : ssh root@128.

emacs -q : no customized
emacs -nw : no windows

C-M-s then regex
M-p(n): search history
M-x occur: words or regex

Friday, July 13, 2007

'/' drove me nuts?

Search for '/' and '/*', '//' show up? You got to check the isearch documents and incremental regexp

[^*]/[^*]

M-x set-variable ENTER case-fold-search ENTER nil ENTER
to make it case sensitive in current buffer tempeoraryly.

Thursday, January 11, 2007

move cursor in emacs

M-m : first character (non-space)

C-M-a : beginning of function

C-M-e : end of function


C-M-f : next structure

C-M-b : last structure

paste (yank) in emacs

use 'browse-kill-ring.el' and add the following in .emacs file
[coolcode]
(require 'browse-kill-ring)
(global-set-key [(control c)(k)] 'browse-kill-ring)
(browse-kill-ring-default-keybindings)[/coolcode]

M-y (or C-c k) to open another frame to show all the copy history, use 'y' or 'i' to paste old one.

ibuffer in emacs

C-x C-b

/m - only show file with same mode
t - choose all
m - mark
u - unmark
v - view
S - save
D - kill buffer

Thursday, January 04, 2007

Emacs Code Browser ECB installation in Emacs

download ecb, eieio, semantic, speedbar and 'tar zxfv xxxx' to ~/emacs directory

modify .emacs file

[coolcode](setq load-path (append load-path '("~/emacs/eieio")))

(setq load-path (append load-path '("~/emacs/semantic")))

(setq load-path (append load-path '("~/emacs/speedbar-0.14beta1")))

(setq load-path (append load-path '("~/emacs/ecb")))

(require 'ecb)

(load "~/emacs/speedbar/speedbar.el") ;; put this one at the end of other el files. [/coolcode]


restart emacs and M-x ecb-activate. A message popup 'ECB requires speedbar[.14beta1, 0.15.9], download from:http://nchc.dl.sourceforge.net/sourceforge/cedet/speedbar-0.14beta1.tar.gz

I think there was a default speedbar there, so specify the location of speedbar.el as above.

Friday, December 01, 2006

Etags

creates tags file: in specified directory, etags -R *

M-x visit-tags-table File

M-. lookfor tags the cursor on

M-, back to original place

C-. open another window and show tags

C-, close tags window

C-M-, search tags, use TAB and mouse mid-button

Tuesday, August 29, 2006

flyspell mode in Emacs

after we use M-flyspell-mode:

The error information: flyspell-mode-on: Symbol's function definition is void: ispell-maybe-find-aspell-dictionaries


Solution: download flyspell.el and follow the link:

http://www-sop.inria.fr/mimosa/Manuel.Serrano/flyspell/flyspell.html

Sunday, July 16, 2006

gdb in emacs

M-x compile (update 4/9/2013: need debug info in your complilation, such as "g++ -g2 test.c")

gdb
file example1 (
update 4/9/2013: example1 is the execuatable file, such as "a.out")
run
break: M-x space (break 19, break tmp1.c:19, break func1)
tbreak: only stop once then gone (temporary)
disable: disable breakpoints
ignore 2 5: skip next 5 corssing of breakpoint
step: step (into the function)
next:
finish: done the function and return
until: run until spcified line
print : check value
set x=3; modify variables
info breakpoints
delete breakpints (delete N)
watch x: will show new and old x when x changes