26 reorder the commits that haven't pushed to the public
git rebase -i HEAD~2
Don't do this once the changesets are pushed to the public.
Monday, 31 October 2016
Saturday, 29 October 2016
emacs 4: Offical Tutorial Part 1
Moving from screen to screen is useful, but how do you
move to a specific place within the text on the screen?
There are several ways you can do this. You can use the arrow keys,
but it's more efficient to keep your hands in the standard position
and use the commands C-p, C-b, C-f, and C-n. These characters
are equivalent to the four arrow keys, like this:
Previous line, C-p
:
:
Backward, C-b .... Current cursor position .... Forward, C-f
:
:
Next line, C-n
Here is a summary of simple cursor-moving operations, including the
word and sentence moving commands:
C-f Move forward a character
C-b Move backward a character
M-f Move forward a word
M-b Move backward a word
C-n Move to next line
C-p Move to previous line
C-a Move to beginning of line
C-e Move to end of line
M-a Move back to beginning of sentence
M-e Move forward to end of sentence
If Emacs stops responding to your commands, you can stop it safely by
typing C-g. You can use C-g to stop a command which is taking too
long to execute.
>> Type C-h k C-f. -- open a new window (like vim split)
See how this window shrinks, while a new one appears
to display documentation on the C-f command.
as well. Here is a summary of the delete operations:
<DEL> Delete the character just before the cursor
C-d Delete the next character after the cursor
M-<DEL> Kill the word immediately before the cursor
M-d Kill the next word after the cursor
C-k Kill from the cursor position to end of line
M-k Kill to the end of the current sentence
move to a specific place within the text on the screen?
There are several ways you can do this. You can use the arrow keys,
but it's more efficient to keep your hands in the standard position
and use the commands C-p, C-b, C-f, and C-n. These characters
are equivalent to the four arrow keys, like this:
Previous line, C-p
:
:
Backward, C-b .... Current cursor position .... Forward, C-f
:
:
Next line, C-n
Here is a summary of simple cursor-moving operations, including the
word and sentence moving commands:
C-f Move forward a character
C-b Move backward a character
M-f Move forward a word
M-b Move backward a word
C-n Move to next line
C-p Move to previous line
C-a Move to beginning of line
C-e Move to end of line
M-a Move back to beginning of sentence
M-e Move forward to end of sentence
If Emacs stops responding to your commands, you can stop it safely by
typing C-g. You can use C-g to stop a command which is taking too
long to execute.
>> Type C-h k C-f. -- open a new window (like vim split)
See how this window shrinks, while a new one appears
to display documentation on the C-f command.
as well. Here is a summary of the delete operations:
<DEL> Delete the character just before the cursor
C-d Delete the next character after the cursor
M-<DEL> Kill the word immediately before the cursor
M-d Kill the next word after the cursor
C-k Kill from the cursor position to end of line
M-k Kill to the end of the current sentence
Undoing Changes
- C-/
- Undo one entry of the undo records—usually, one command worth
(
undo). - C-x u
- C-_
- The same.
>> Move the cursor to the beginning of a line which is not empty.
Then type C-k to kill the text on that line.
>> Type C-k a second time. You'll see that it kills the Newline
which follows that line.
This blog covers contents until line 453 of official tutorial
emacs 3: 避免门户之见
所谓门户之见就是贴标签.”我们的”对应”他们的”.”熟悉的”对应”陌生的”,”正统的”对应”异端”的.
“我们的”,”熟悉的”,”正统的”,就是”好的”;”他们的”,”陌生的”,”异端的”就是”坏的”.
比如用了Emacs就排斥Vim的快捷键,或者反之.
避免门户之见的关键就是意识到标签只存在于你的主观想像中.真实世界不会因为你的想像而扭曲.
以Emacs和Vim的快捷键为例,两种快捷键完全可以无缝接合.
当然思想的问题不是我空谈能解决的,关键是要实干.一个很好的治愈方法就是把http://planet.emacsen.org/上约4000篇文章通读一遍.大约需要8个小时左右.泛读就可以了.目的就是了解世界有多大.
jyj407: 作者这里说的很好,凡是好的东西,我们都可以拿来为我所用,无论是vim 还是 emacs,也不管是Windows还是Unix、Linux, 抑或C++ vs Java 它们都是各有千秋,优缺互补。避免门户观点,始终保持开放的心态很重要。
原文链接:
https://github.com/redguardtoo/mastering-emacs-in-one-year-guide/blob/master/guide-zh.org
Friday, 28 October 2016
emacs 2 移动和导航
表 3. 有用的 Emacs 键盘输入(用于移动和导航)
| 键盘输入 | 函数 | 描述 |
|---|---|---|
C-p,UpArrow | previous-line | 将插入点向上移动到上一行。 |
C-n, DownArrow | next-line | 将插入点向下移动到下一行。 |
C-f, RightArrow | forward-char | 将插入点移动到下一个字符。 |
C-b, LeftArrow | back-char | 将插入点移动到上一个字符。 |
M-f | forward-word | 将插入点移动到下一个单词。 |
M-b | backward-word | 将插入点移动到上一个单词。 |
C-v, PgDn | scroll-up | 将文本向上滚动一屏。 |
M-v, PgUp | scroll-down | 将文本向下滚动一屏。 |
Home | beginning-of-buffer | 将插入点移到缓冲区的开始处。(在某些版本中,这个键被缺省定义为移动到当前行的开始处。) |
End | end-of-buffer | 将插入点移到缓冲区的末尾。(在某些版本中,这个键被缺省定义为移动到当前行的末尾。) |
C-a | beginning-of-line | 将插入点移到本行的开始处。 |
C-e | end-of-line | 将插入点移到本行的结尾。 |
M-a | beginning-of-sentence | 将插入点移到句子的开始处。 |
M-e | end-of-sentence | 将插入点移到句子的结尾处。 |
M-{ | beginning-of-paragraph | 将插入点移到段落的开始处。 |
M-} | end-of-paragraph | 将插入点移到段落的结尾处。 |
Thursday, 27 October 2016
emacs 1 进入与退出
进入退出emacs
1. 进入 emacs:
Unix 系统下: emacs file_name
例如: emacs hello.cpp
2. 退出emcas:
比较文明的方法,C-x C-c ,如果当前文件已经修改会问你是否保存。
野蛮点的方法,调用函数kill-emacs,即M-x kill-emacs,直接退出,不管是否修改。
不过直接退出后,Emacs会在相同目录下保留一个以#号开头结尾的相同文件名文件,下次启动可以使用M-x recover-file来恢复。如果是多次保存后,还会有个以~结尾的文件,保存了上次信息。
1. 进入 emacs:
Unix 系统下: emacs file_name
例如: emacs hello.cpp
2. 退出emcas:
比较文明的方法,C-x C-c ,如果当前文件已经修改会问你是否保存。
野蛮点的方法,调用函数kill-emacs,即M-x kill-emacs,直接退出,不管是否修改。
不过直接退出后,Emacs会在相同目录下保留一个以#号开头结尾的相同文件名文件,下次启动可以使用M-x recover-file来恢复。如果是多次保存后,还会有个以~结尾的文件,保存了上次信息。
Wednesday, 26 October 2016
git rebase 1
Never make any changes on master!
git checkout master
git pull
git checkout dev
git rebase master
if conflicts:
manually resolve the conflicts in vi
git rebase --continue
git checkout master
git pull
git checkout dev
git rebase master
if conflicts:
manually resolve the conflicts in vi
git rebase --continue
Tuesday, 25 October 2016
More git commands (3)
21. How to create a git diff patch?
git diff -U999999 other-branch > file
git diff change_id > file
22. git merge when conflicts
I modified both the same file on branch dev and branch master
when I try to merge what I have on dev to master, I have a conflict
You can manually merge them and mark them as merged. However, if you
don't need the master changeset, you can discard that one, so it will
automatically merge successfully.
First use git reset to go back to the state that doesn't have you changes
git checkout master
git reset --hard 472fc9d1f1236af7c8183b89670e6c4035503ab8
And then:
git merge dev
23. git stash
24. git pull
before push do:
git pull --rebase
to rebase you currrent branch, if no conflicts you can push directly.
25. What could cause you fail to build? Some error from the new changes?
If you are on dev branch and try to pull from master, git won't update your dev branch
using remote origin master, you have to switch master branch and do a git pull --rebase there.
Make sure you do a git pull for both clang and llvm master.
git diff -U999999 other-branch > file
git diff change_id > file
22. git merge when conflicts
I modified both the same file on branch dev and branch master
when I try to merge what I have on dev to master, I have a conflict
You can manually merge them and mark them as merged. However, if you
don't need the master changeset, you can discard that one, so it will
automatically merge successfully.
First use git reset to go back to the state that doesn't have you changes
git checkout master
git reset --hard 472fc9d1f1236af7c8183b89670e6c4035503ab8
And then:
git merge dev
23. git stash
24. git pull
before push do:
git pull --rebase
to rebase you currrent branch, if no conflicts you can push directly.
25. What could cause you fail to build? Some error from the new changes?
If you are on dev branch and try to pull from master, git won't update your dev branch
using remote origin master, you have to switch master branch and do a git pull --rebase there.
Make sure you do a git pull for both clang and llvm master.
Sunday, 23 October 2016
more git commands (2)
10. Adding All Changes
You also can use wildcards if you want to add many files of the same type. Suppose that I've added a bunch of .txt files into
your directory.I put some in a directory named "octofamily" and some others ended up in the root of our "octobox" directory.
Luckily, we can add all the new files using a wildcard with git add. Don't forget the quotes!
git add '*.txt'
11. To push our local repo to the GitHub server we'll need to add a remote repository.
git remote add origin https://github.com/try-git/try_git.git
12. Pushing Remotely
git push -u origin master
13. Pulling Remotely
14. git reset
You can unstage files by using the git reset command.
git reset octofamily/octodog.txt
15. git rm
git rm command which will not only remove the actual files from disk,
but will also stage the removal of the files for us
git rm '*.txt'
16. git merge
merge your changes from the clean_up branch into the master branch:
git merge clean_up
17. git help
run git help to bring the manual
git help
git help config
18. git add --all
add all the deleted, newly added or modified files to the staged area.
19 git add <list of files>
like git add readme.txt a.c b.h
20 git add directory
git add /home/jtony/src/
will add all the changes under src directory.
Friday, 21 October 2016
more git command (1)
9. git push
pushing changes
Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository, execute
git push origin master
Change master to whatever branch you want to push your changes to.
If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it with
git remote add origin <server>
Now you are able to push your changes to the selected remote server
10. git branch
git branch dev
checkout branch
branching
Branches are used to develop features isolated from each other. The master branch is the
"default" branch when you create a repository.
Use other branches for development and merge them back to the master branch upon completion.
create a new branch named "feature_x" and switch to it using
git checkout -b feature_x
switch back to master
git checkout master
and delete the branch again
git branch -d feature_x
a branch is not available to others unless you push the branch to your remote repository
git push origin <branch>
pushing changes
Your changes are now in the HEAD of your local working copy. To send those changes to your remote repository, execute
git push origin master
Change master to whatever branch you want to push your changes to.
If you have not cloned an existing repository and want to connect your repository to a remote server, you need to add it with
git remote add origin <server>
Now you are able to push your changes to the selected remote server
10. git branch
git branch dev
checkout branch
branching
Branches are used to develop features isolated from each other. The master branch is the
"default" branch when you create a repository.
Use other branches for development and merge them back to the master branch upon completion.
create a new branch named "feature_x" and switch to it using
git checkout -b feature_x
switch back to master
git checkout master
and delete the branch again
git branch -d feature_x
a branch is not available to others unless you push the branch to your remote repository
git push origin <branch>
Thursday, 20 October 2016
basic git commands
This summary is not available. Please
click here to view the post.
Sunday, 9 October 2016
Tmux/Screen commands
Tmux
1. create a new session named work
tmux new-session -s work
2. kill window 4 in another window
tmux kill-window -t 4
3. show all sessions
tmux ls
(note that is no - "dash" before ls!!)
Screen
1. quit/kill screen session: -- CAREFULL!!
screen -X -S 6829 quit
2. quick create a screen session:
3 How to swap windows?
The swap-window command is closest to what you want.
"Prefix :" (that is "Ctrl-B :" by default) brings you to the tmux-command prompt. There you enter:
swap-window -s 3 -t 1
1. create a new session named work
tmux new-session -s work
2. kill window 4 in another window
tmux kill-window -t 4
3. show all sessions
tmux ls
(note that is no - "dash" before ls!!)
Screen
1. quit/kill screen session: -- CAREFULL!!
screen -X -S 6829 quit
2. quick create a screen session:
3 How to swap windows?
The swap-window command is closest to what you want.
"Prefix :" (that is "Ctrl-B :" by default) brings you to the tmux-command prompt. There you enter:
swap-window -s 3 -t 1
Subscribe to:
Posts (Atom)