Sunday, 27 November 2016

Emacs 7: Offical Tutorial Part 6

Did you see what happened?  Emacs, in an incremental search, tries to
go to the occurrence of the string that you've typed out so far.  To
go to the next occurrence of 'cursor' just type C-s again.  If no such
occurrence exists, Emacs beeps and tells you the search is currently
"failing".  C-g would also terminate the search.

>> Type C-x 1 (in the top window) to get rid of the bottom window.

(If you had typed C-x 1 in the bottom window, that would get rid
of the top one.  Think of this command as "Keep just one
window--the window I am already in."
)

Line 941

Emacs 6: Offical Tutorial Part 5


There are many C-x commands.  Here is a list of the ones you have learned:

        C-x C-f         Find file
        C-x C-s         Save file
        C-x s           Save some buffers
        C-x C-b         List buffers
        C-x b           Switch buffer
        C-x C-c         Quit Emacs
        C-x 1           Delete all but one window
        C-x u           Undo

>> Move the cursor to the blank line two lines below this one.
   Then type M-x repl s<Return>changed<Return>altered<Return>.

   Notice how this line has changed: you've replaced the word
   "changed" with "altered" wherever it occurred, after the
   initial position of the cursor.

Friday, 25 November 2016

How to generate the ssh key on unix and add it to git hub?


(a)ssh-keygen -t rsa -C "jtony@ca.ibm.com"
(b)When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.
(c)At the prompt, type a secure passphrase, press Enter to not use passphrase
(d) Enter the secure passphrase again, or press Enter again to confirm null passphrase.
(e) copy the  ~/.ssh/id_rsa.pub content
(f) Go to git hub and click on New     SSH Key, enter the Tile for the key and paste the copied content to the Key field and click
    on Add SSH Key.
https://www.racf.bnl.gov/docs/authentication/ssh/sshkeygenunix

Thursday, 24 November 2016

Emacs 5: Offical Tutorial Part 4

>> Type C-x b *Messages* <Return> to look at the buffer of messages.
   Then type C-x b TUTORIAL <Return> to come back to this tutorial.


C-x s     Save some buffers

C-x s asks you about each buffer which contains changes that you have
not saved.  It asks you, for each such buffer, whether to save the
buffer.

>> Insert a line of text, then type C-x s.
   It should ask you whether to save the buffer named TUTORIAL.
   Answer yes to the question by typing "y".

Line 635

How to move the cursor to its last position in vim?

The quickest way is to hit either:

''

(two apostrophes) or:

``

(two backticks). Note that the difference is that the backtick goes to the same location on the line, whereas the apostrophe goes to the start of the line. On a UK keyboard, the apostrophe is more accessible, so I tend to use that one. There are loads of useful marks like this, see :help mark-motions.

For some other motions (not 2j I think), there's also the jump-list that lets you navigate back and forth among a number of motions. Ctrl-O and Ctrl-I do this navigation, but see :help jump-motions for more information.




Original link on stackoverflow:
http://stackoverflow.com/questions/5052079/move-cursor-to-its-last-position

Tuesday, 22 November 2016

How to use ctags (basics) ?



jtony@genoa:~/src/llvm$ ctags -R .
if you want to just to a definition of a funciton, move the cursor to the function and press ctrl + ]
If there is only one match, it will take you there. If there are multiple matches, it will list them all,
letting you choose the one you want, just like :tselect. The best of both worlds. :)

if you want to go back where you jumped from, press ctrl + t

Friday, 18 November 2016

using git apply to apply a patch

Before apply the patch, we have to creat it first.
git format-patch master --stdout > fix_empty_poster.patch
This will create a new file fix_empty_poster.patch with all changes from the current (fix_empty_poster) against master.

Now apply it. First, take a look at what changes are in the patch. You can do this easily with git apply
git apply --stat fix_empty_poster.patch
Next, you’re interested in how troublesome the patch is going to be. Git allows you to test
the patch before you actually apply it.
git apply --check fix_empty_poster.patch

You can do "git apply [patch-name].patch" (Haven't try that.)

But I’ll use git am instead of git apply. The reason for this is that git am allows you to sign off an applied patch.
This may be useful for later reference.

Thursday, 17 November 2016

emacs 4: Offical Tutorial Part 3

>> Type C-x 1 to get rid of the buffer list.

When you have several buffers, only one of them is "current" at any
time.  That buffer is the one you edit.  If you want to edit another
buffer, you need to "switch" to it.  If you want to switch to a buffer
that corresponds to a file, you can do it by visiting the file again
with C-x C-f.  But there is an easier way: use the C-x b command.
In that command, you have to type the buffer's name.

>> Create a file named "foo" by typing C-x C-f foo <Return>.
   Then type C-x b TUTORIAL <Return> to come back to this tutorial.




Line 582

Calculate and print the summation of a column using awk

 Calculate the summation of all the number in column 1 in file test.txt and print out the result.

cat test.txt |  awk '{s+=$1} END {printf "%.0f\n", s}'


http://stackoverflow.com/questions/450799/shell-command-to-sum-integers-one-per-line

Tuesday, 15 November 2016

emacs 4: Offical Tutorial Part 2

From line 454:

Use Meta + g, Meta + g to bring up the Goto line: mode at the bottom, then enter the line number that you want to jump to and enter, the editor will take you to that line.

Use C-/ to undo things because this is the most convenient way of typing,   much easier than C-/_ and C-x u ( three keys).

One special thing about the command for finding a file is that you
have to say what file name you want.  We say the command "reads an
argument" (in this case, the argument is the name of the file).  After
you type the command

        C-x C-f   Find a file

Emacs asks you to type the file name.  The file name you type appears
on the bottom line of the screen.  The bottom line is called the
minibuffer when it is used for this sort of input.  You can use
ordinary Emacs editing commands to edit the file name.

While you are entering the file name (or any minibuffer input),
you can cancel the command with C-g.

To Line 553

Monday, 14 November 2016

git log --author option

30. How to just show log of one author?
git log --author=jtony

git squash



31. How to do a git squash?
e.g. If I want to squash the two commits on HEAD.
(a) git rebase -i HEAD~2
git will bring all a editor with the following message:
pick 8157e2b Test 1.
pick 05532ed Test 2.

(b) change the second 'pick' to 'squash', which means squash
commit 2 (Test2) into commit 1 (Test1)

(c) Save and quite.  git will combine the two commits together and
bring up a new editor. Like:
# This is a combination of 2 commits.
# The first commit's message is:

Test 1.

# This is the 2nd commit message:

Test 2.
 Edit the message again and save and quite. Like
Test1 && Test2

Successfully rebased and updated refs/heads/master.

If you do a 'git log' after the combination, you will find
the new combined log as follows:

commit 77fd2899a713aefcb0d3369fe17d12d9552e5cec
Author: Tony Jiang <jtony@ca.ibm.com>
Date:   Mon Nov 14 20:03:34 2016 -0600

    Test 1 && Test 2.



Sunday, 13 November 2016

VIM Advanced 3

翻页移动
ctrl+f 向下翻整页
ctrl+b 向上翻整页
ctrl+d 向下翻半页
ctrl+u 向上翻半页

Wednesday, 9 November 2016

VIM advanced 2

4. How to set up the vimrc and syntax hightlight (using clang rules)?
cd ~/.vim/
mkdir syntax && cd syntax
cp ~/src/llvm/utils/vim/syntax/*  .
cp ~/src/llvm/utils/vim/vimrc  ~/.vimrc

Tuesday, 8 November 2016

VIM advanced 1

1. search current word
shift + 8  (ie., *)

2. open two file, and split them in two windows
split files horizontally:
vim lib/Headers/altivec.h jyj.format -o
split files vectically:
vim lib/Headers/altivec.h jyj.format -O

3. substitute contents that contains "[","]" need escape char, like
replace "e[" with   "(int)e["
:%s/e\[/(int)e\[/gc

Thursday, 3 November 2016

more git command (git svn, git cherry-pick)

27. git cherry-pick
Apply the changes introduced by some existing commits
I have a commit on dev, which has conflicts with current master,
I checkout a new branch new_dev, and cherry-pick the top commit on dev
and apply it to new_dev, if there is no conflicts, you don't have to
merge the conflicts for other commits, just cherry-pick  the useful commit and
discard all the other commits.

git cherry-pick a96001889dfe2259aca963ae3380900eaad406fa
http://blog.csdn.net/wh_19910525/article/details/7554430


28. Use git svn to commit a git changeset to svn repository
git svn dcommit --interative

Tuesday, 1 November 2016

windows 目录切换快捷键


当我们打一个文件夹或更深层次的目录需要返回上一级文件夹时可,按backspace键可以       退到上一级目录文件,这个键我们平时用于删除光标前一个字符比较多!!
      
 table键可以在当前文件夹内的项目中正序选择
   如果是shift 和table一起按,则可以倒序选择
   
很实用的,希望给大家带来方便!!!

http://www.7edown.com/edu/article/soft_4392_1.html