Tools (工具)
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.
Subscribe to:
Posts (Atom)