Sunday, 9 July 2017
Disabling auto indent temporarily to pasteEdit
Sometimes you only need to paste some snippet of code, that already has indentation, so you can disable it only during the paste operation:
:set paste
then
:set nopaste
Saturday, 10 June 2017
111. What could cause right click in putty session always insert Ctrl + c?
It is a putty problem, just install(maybe reinstall old version also work) the latest version, the problem is fixed.
I don't think it is because configuration, because after reinstall my other confguration is still there ( like font size, type), only the problem is resolved.
Wednesday, 24 May 2017
How to replace all %0,%1,%2,%3 to %{{[0-9]+}} in vim?
(a)Select the text you want to replace.
(b) :%s#%[0-4]#%{{[0-9]+}}#gc
It is just one key.
before:
// CHECK-LABEL: xxsldwi_should_not_assert
// CHECK: bitcast <2 x double> %0 to <4 x i32>
// CHECK-NEXT: bitcast <2 x double> %1 to <4 x i32>
// CHECK-NEXT: shufflevector <4 x i32> %2, <4 x i32> %3, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
// CHECK-NEXT: bitcast <4 x i32> %4 to <2 x double>
after:
// CHECK-LABEL: xxsldwi_should_not_assert
// CHECK: bitcast <2 x double> %{{[0-9]+}} to <4 x i32>
// CHECK-NEXT: bitcast <2 x double> %{{[0-9]+}} to <4 x i32>
// CHECK-NEXT: shufflevector <4 x i32> %{{[0-9]+}}, <4 x i32> %{{[0-9]+}}, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
// CHECK-NEXT: bitcast <4 x i32> %{{[0-9]+}} to <2 x double>
Tuesday, 23 May 2017
Break a previous commit into multiple commits? (How to split patches using git?)
git rebase -i will do it.
To split apart your most recent commit, first:
$ git reset HEAD~
Now commit the pieces individually in the usual way, producing as many commits as you need.
If it was farther back in the tree, then
$ git rebase -i HEAD~3
where 3 is how many commits back it is.
If it was farther back in the tree than you want to count, then
$ git rebase -i 123abcd^
where 123abcd is the SHA1 of the commit you want to split up.
When you get the rebase edit screen, find the commit you want to break apart. At the beginning of that line, replace pick with edit (e for short). Save the buffer and exit. Rebase will now stop just after the commit you want to edit. Then:
$ git reset HEAD~
Commit the pieces individually in the usual way, producing as many commits as you need, then
$ git rebase --continue
Tuesday, 28 March 2017
sed delete/insert/replace
101. How to delete lines using sed?
delete line 1-3
sed -i '1,3d' test.txt
delete line 2,5,8
sed -i '2d;5d;8d' testComparesllequ*.ll
Remove the line containing the string "awk," by using:
sed '/awk/d' filename.txt
sed -i '/; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py/d'
102. How to insert a line using sed?
sed -i '1 i\
; RUN: llc -verify-machineinstrs -mtriple=powerpc64le-unknown-linux-gnu testComparesiequ*.ll
103. sed replace a line:
sed 's/hello/bonjour/' greetings.txt
Replacing in-place -i
sed ships with the -i flag. Let’s consult man sed:
sed -i 's/hello/bonjour/' greetings.txt
Monday, 27 March 2017
How to open vim and go to a specific line?
add +NUMBER after the vim file command, like:
vim test/jtony.ll +123
This will open file test/jtony.ll and goto line 123.
Friday, 24 March 2017
awk practice
$ cat /home/sfertile/bin/capture_dot
#!/bin/bash
grep Writing | awk -F\' '{print $2}'
#!/bin/bash
grep Writing | awk -F\' '{print $2}'
This script grep the lines that contains "Writing" and then split the lines into different columns using the ' symbol seperator, and print the second element after splitting.
It is equivalent to :
grep Writing | awk -F "'" '{print $2}'
if we ignore, -F, the default separator will be space.
Friday, 24 February 2017
Revert changes in git
(1) How to revert files that are not staged in git?
For a specific file use:
git checkout path/to/file/to/revert
For all unstaged files use:git checkout -- .
OR:
git checkout .
(2) How to unstage a staged file?
git reset path/to/file/to/revert
(3) Is there a way to delete staged file completely?
No, git reset will only unstage the staged files, it won't delete the changes,
if you want to delete it completely, you have to do git checkout in step one.
Thursday, 16 February 2017
42. How to show where the current repo is pulled from?
git remote show origin
* remote origin
Fetch URL: git@github.ibm.com:llvm/llvm-on-power.git
Push URL: git@github.ibm.com:llvm/llvm-on-power.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
Sunday, 12 February 2017
emcas replace-rectangle
Command Key Purpose
replace-rectangle 【Ctrl+x r t】 Replace text in a selected column.
try change this
3c21 646f 6374
6874 6d6c 3e3c
2063 6861 7273
202f 3e0a 3c6d
6965 7770 6f72
2277 6964 7468
to this
3c21 cat 6374
6874 cat 3e3c
2063 cat 7273
202f cat 3c6d
6965 cat 6f72
2277 cat 7468
Put your cursor before “646f”.
Call set-mark-command 【Ctrl+Space】.
Move cursor to end of “6964”.
Call replace-rectangle 【Ctrl+x r t】.
Saturday, 11 February 2017
How to Split Windows in Emacs?
How to Split Windows in Emacs?
C-x 2
- Split the selected window into two windows, one above the other
(
split-window-below). - C-x 3
- Split the selected window into two windows, positioned side by side
(
split-window-right).
In order to exit splitting windows mode, you have to use:
C-x 0
to quit the current window
C-x 1
to quit all the extended window, i.e just leave one copy of the same view.
Friday, 3 February 2017
What is the difference between emacs and vim?
From Stackoverflow:
http://stackoverflow.com/questions/1430164/differences-between-emacs-and-vim
"With Emacs you are expected to have it open 24/7 and live inside the program, almost everything you do can be done from there. You write your own extensions, use it for note taking, organisation, games, programming, shell access, file access, listening to music, web browsing. It takes weeks and weeks till you will be happy with it and then you will learn new stuff all the time. You will be annoyed when you don't have access to it and constantly change your config. You won't be able to use other peoples emacs versions easily and it won't just be installed. It uses Lisp, which is great. You can make it into anything you want it to be. (anything, at all)
With vim, it's almost always pre-installed. It's fast. You open up a file do a quick edit and then quit. You can work with the basic setup if you are on someone else's machine. It's not quite so editable; but it's still far better than most text editors. It recognises that most of the time you are reading/editing not typing and makes that portion faster. You don't suffer from emacs pinkie. It's not so infuriating. It's easier to learn."
In my opinion:
Vim mode switch is annoying and also slow. Although emacs need to type more keys for most of the
editing task, but since you don't need to switch between different mode, so it is still faster when you are familiar with it. Also as mentioned here, it is more extendable and can used everywhere (gdb, shell) etc.
http://stackoverflow.com/questions/1430164/differences-between-emacs-and-vim
"With Emacs you are expected to have it open 24/7 and live inside the program, almost everything you do can be done from there. You write your own extensions, use it for note taking, organisation, games, programming, shell access, file access, listening to music, web browsing. It takes weeks and weeks till you will be happy with it and then you will learn new stuff all the time. You will be annoyed when you don't have access to it and constantly change your config. You won't be able to use other peoples emacs versions easily and it won't just be installed. It uses Lisp, which is great. You can make it into anything you want it to be. (anything, at all)
With vim, it's almost always pre-installed. It's fast. You open up a file do a quick edit and then quit. You can work with the basic setup if you are on someone else's machine. It's not quite so editable; but it's still far better than most text editors. It recognises that most of the time you are reading/editing not typing and makes that portion faster. You don't suffer from emacs pinkie. It's not so infuriating. It's easier to learn."
In my opinion:
Vim mode switch is annoying and also slow. Although emacs need to type more keys for most of the
editing task, but since you don't need to switch between different mode, so it is still faster when you are familiar with it. Also as mentioned here, it is more extendable and can used everywhere (gdb, shell) etc.
Wednesday, 1 February 2017
emacs Erasing Text
- DEL
- BACKSPACE
- Delete the character before point, or the region if it is active (
delete-backward-char). - Delete
- Delete the character after point, or the region if it is active (
delete-forward-char). - C-d
- Delete the character after point (
delete-char). - C-k
- Kill to the end of the line (
kill-line). - M-d
- Kill forward to the end of the next word (
kill-word). - M-DEL
- Kill back to the beginning of the previous word (
backward-kill-word).
How to copy and past a line in emcas?
down voteaccepted
|
which breaks down to
|
Tuesday, 31 January 2017
git clean ( 清理)
git clean ( 清理)
有时,Git会提示“untracked working tree files”会“overwritten by checkout”。造成这种情况的原因有很多。不过通常来说,我们可以使用如下命令来保持工作树的整洁,从而防止这种情况的发生:
$ git clean -f # remove untracked files $ git clean -fd # remove untracked files/directories $ git clean -nfd # list all files/directories that would be removed
Friday, 27 January 2017
emacs 按列块删除
“emacs 里面那个默认的列编辑不会出来像 vim 里面那样的矩形选区(不过有别的方法好像可以做到),所以当你选择的时候,还是按行来选择的,你只需要关心选择的起始点和结束点之间的那个矩形就好了,你的操作只会在里面起作用。” 之前我总是视图用vim 的方式理解emacs, 发现每次ctrl + x + r + k 都不能删除列方块,原来emacs 根本不会像vim 那样标记列矩阵块!而是从开始行的开始字符到终止行的终止字符直接所有的内容都被高亮选中,但是不用担心,删除的时候实际只会删除开始字符和终止字符直接的矩形块,别的会保留! ~ 看来转换思维很重要。

4. Call
kill-rectangle
try to delete the middle column 3c21 646f 6374 6874 6d6c 3e3c 2063 6861 7273 202f 3e0a 3c6d 6965 7770 6f72 2277 6964 7468
| Command | Key | Purpose |
|---|---|---|
kill-rectangle | 【Ctrl+x r k】 | Delete selected column of text. |
- Put your cursor before “646f”.
- Call
set-mark-command【Ctrl+Space】. - Move cursor to end of “6964”. (move down 5 lines and right 3 columns). At this time, the screen will looks like below (unlike vim, only the middle columns to be deleted are marked)

4. Call
kill-rectangle. Wednesday, 25 January 2017
Ways to copy directory from one machine to another
There are several ways you can achieve this goal. Two the common ways are using rsync and scp.
(1) rsync
(1) rsync
rsync -a dir1/ dir2
This will archive and copy directory dir1 recursively to dir2.
The -a option is a combination flag.
It stands for "archive" and syncs recursively and preserves symbolic links, special and device files, modification times, group, owner, and permissions.
If you want to copy to another machine as destination. Just add the machine full name as the prefix for
dir2.
syntax:
rsync -a dir1/ user_name@neodynium.bell.ca:dir2
e.g:
rsync -a test1/ jyj407@tj12.zte.com.cn:test2
The above command copies test1 directory recursively from the current machine to the remote
tj12.zte.com.cn machine directory test2. Here, ':' colon symbol stands for the home directory for user
jyj407.
(2) Another way is use scp.
scp -r dir1/ user_name@neodynium.bell.ca:dir2
The scp command is similar to rsync, but slower than rsync, especially for large directory with
tons of files. Also rsync does incremental copy, scp will copy everything. So generally speaking,
I would recommend using 'rsync' instead of 'scp'.
Tuesday, 24 January 2017
gdb basics tutorial
Note these commands are universal except the first two are specific for llvm build and debug. For other application you want to debug, simply build a debug version using your own way (either make or cmake), then just 'gdb yourApplication' . For some complex applications you may need --args to pass some flags.
(1) Build a debug version executable.
(1) Build a debug version executable.
cmake
-DGCC_INSTALL_PREFIX=/home/llvm/gcc/install/gcc-6.2.0 -DCMAKE_BUILD_TYPE="Debug" -DBUILD_SHARED_LIBS=ON
-DLLVM_ENABLE_ASSERTIONS=ON ~/src/llvm ;
make -j20
(2)
Start gdb:
gdb --args
/home/jtony/debug/bin/llc test/CodeGen/PowerPC/expand-isel.ll
(3)
Query function:
info func expandMergeableISELs (info func MergeableISEL also works, fuzzy
matching?)
(4)
Set break points:
Function
breakpoint:
b[reak] function_name
e.g: b(reak) PPCExpandISEL::expandMergeableISELs
set breakpoint
at a specified file-line pair:
b[reak] file.cpp:7
break current
line:
b[reak]
conditional
break is also allowed: b[reak]
file.cpp:7 if a > 5
(5)
Start the program and run to
breakpoint
r[un]
Run to next
breakpoint:
c[ontinue]
typing r(un) again would restart the program from beginning
(6)
Switch to TUI mode
lay src (ctrl + x + a)
Step
into: ‘s[tep]’ -- will go into a function call,
and walk through every line of code
Step
over: ‘n[ext]’ -- treat function call as one
instruction, won’t go into it
Step out: ‘fin[ish]’ --
finish the rest of the function call and return to the caller
Note: press ENTER gdb
will repeat the same command you just gave to it
Save
breakpoints: save breakpoints filename
Reload
breakpints: source filename
Show
breakpoints: ‘info break’
‘show
commands’
Print value of
a variable: p[rint] varName
Print in hexadecimal:
p[rint]/x
varName
print the type
of var: ptype ‘varName’
Print calling
stack: ‘where’ or ‘backtrace’
Navigate
between calling stack:
Go up one
level: ‘up’
Go down one
level: ‘down’
Go up N level: ‘up N’
Go down N
level; ‘down N’
refresh the
screen: ‘refresh’
call a
function: call function_name(parameters)
(13) jump to a line
(not safe, unpredictable, unless you know what you are doing)
First set a break point on the
line you want to jump to: b[reak] line_number e.g
b 321
Then jump line number: jump line_number e.g jump 321
New skills learned during the tutorial:
n(ext) N will step over N steps, if
N = 1, is equivalent to just n(ext)
Thursday, 12 January 2017
git clean
40. How to remove all the untrack files in the current branch?
Step 1 is to show what will be deleted by using the -n option:
git clean -n
Clean Step - beware: this will delete files:
git clean -f
Ref: http://stackoverflow.com/questions/61212/how-to-remove-local-untracked-files-from-the-current-git-branch
Step 1 is to show what will be deleted by using the -n option:
git clean -n
Clean Step - beware: this will delete files:
git clean -f
Ref: http://stackoverflow.com/questions/61212/how-to-remove-local-untracked-files-from-the-current-git-branch
git revert
How to revert one commit (may not be the HEAD one) ?
git revert commit_number
git revert 6d80fe73c689b51358b05cc945a53c44a092ebe3
git revert commit_number
git revert 6d80fe73c689b51358b05cc945a53c44a092ebe3
Wednesday, 11 January 2017
What is GNU Libtool?
Introduction to GNU Libtool
GNU libtool is a generic library support script. Libtool hides the complexity of using shared libraries behind a consistent, portable interface.To use libtool, add the new generic library building commands to your Makefile, Makefile.in, or Makefile.am. See the documentation for details.
Ref:
https://www.gnu.org/software/libtool/libtool.html
VIM: Deleting from current position until a character
Switch to command mode in vim and then try d + t + space. In general d + t + x deletes from current position till just before
To delete up to and including the space, use d + f + space (or d + t + space)
x. Just t + x moves the cursor to just before character x in current line.To delete up to and including the space, use d + f + space (or d + t + space)
Reference: http://stackoverflow.com/questions/1607904/vim-deleting-from-current-position-until-a-space
Tuesday, 10 January 2017
Emacs editing by column
For example here is the text I want to edit:
foo
foo
foo
And here is the text result I want to have:bar foo
bar foo
bar foo
Use rectangles (as mentioned in another answer).
The explicit directions for that are:
- goto first line, first column
- Ctrl-Space
- goto last line (first column)
- Ctrl-x r t bar space RET
Subscribe to:
Posts (Atom)