Skip to content

Commit 4226ca1

Browse files
committed
so.vim to .vimrc
1 parent 5be8280 commit 4226ca1

File tree

9 files changed

+43
-32
lines changed

9 files changed

+43
-32
lines changed

.vimrc

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
" Used on directories that compile files individually (e.g. c.c -> c and cpp.cpp -> cpp)
2+
" <F5>: compile all
3+
" <F6>: compile and run the current file
4+
5+
function! RedirStdoutNewTabSingle(cmd)
6+
tabnext
7+
if expand('%:p') != ""
8+
tabprevious
9+
execute "tabnew"
10+
setlocal buftype=nofile
11+
setlocal bufhidden=wipe
12+
setlocal noswapfile
13+
endif
14+
%delete
15+
execute "silent read !" . a:cmd
16+
set nomodified
17+
endfunction
18+
19+
function! MapAllBuff(keys, rhs)
20+
exe 'noremap <buffer>' a:keys a:rhs
21+
exe 'noremap! <buffer>' a:keys '<ESC>'.a:rhs
22+
endfunction
23+
24+
call MapAllBuff( '<F5>' , ':w<CR>:make<CR>' )
25+
if expand('%:e') =~ '\(c\|cpp\|f\)'
26+
call MapAllBuff( '<F6>' , ':call RedirStdoutNewTabSingle("make run=''\"' . expand('%:r') . '\"''")<CR>' )
27+
call MapAllBuff( '<F9>' , ':call RedirStdoutNewTabSingle("make profile=''\"' . expand('%:r') . '\"''")<CR>' )
28+
else
29+
call MapAllBuff( '<F6>' , ':call RedirStdoutNewTabSingle("make run")<CR>' )
30+
call MapAllBuff( '<F9>' , ':w<CR>:call RedirStdoutNewTabSingle("make profile")<CR>' )
31+
endif

Makefile_many

+6-1
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ IN_EXTS ?= .c .cpp .f
4646
OUT_DIR ?= _out/
4747
OUT_EXT ?= #.elf
4848

49-
# Basename without extension of file to run:
49+
# Basename without extension of file to run on run target.
5050
RUN ?= main
51+
# Allow users to write `make run=name`.
52+
run ?=
5153

5254
ASSEMBLER_NOEXT ?= $(IN_DIR)$(RUN)
5355
DEBUG_DEFINE ?=
@@ -70,6 +72,9 @@ OUTS := $(addprefix $(OUT_DIR), $(OUTS_NODIR))
7072
.PHONY: all asm set_asm_flags clean debug set_debug_flags help mkdir objdump set_objdump_flags profile set_profile_flags $(PHONY)
7173

7274
all: mkdir $(OUTS)
75+
ifneq ($(strip $(run)),)
76+
cd $(OUT_DIR) && ./"$(run)"
77+
endif
7378

7479
$(OUT_DIR)%$(OUT_EXT): $(IN_DIR)%.c
7580
$(MYCC) $(CFLAGS) $(PROFILE_DEFINE) $(PROFILE_FLAGS) $(DEBUG_DEFINE) $(DEBUG_FLAGS) $(OPTIMIZE_FLAGS) $(INCLUDE_DIRS) -o "$@" "$<" $(LIBS)

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ To compile and run each directory on Ubuntu 12.04 do:
99
make install-ubuntu
1010
make run
1111

12-
You *must* run `make install-ubuntu` on the top-level before compiling any subdirectories.
12+
You *must* run `make install-ubuntu` on the top-level before compiling any subdirectories, as this will install basic tools such as recent enough `gcc` and `g++` for C11 and C++11.
1313

1414
When there are multiple files compiled, e.g.:
1515

@@ -18,8 +18,8 @@ When there are multiple files compiled, e.g.:
1818

1919
run a given file by specifying the basename without extension:
2020

21-
make run RUN=c
22-
make run RUN=cpp
21+
make run=c
22+
make run=cpp
2323

2424
Doing just `make run` in those cases will run the default file.
2525

cpp.cpp

+3-14
Original file line numberDiff line numberDiff line change
@@ -7422,27 +7422,16 @@ int main(int argc, char **argv)
74227422
shall only be cheated here once.
74237423
*/
74247424
{
7425-
//create
7425+
// Create
74267426
{
7427-
//empty
7427+
// Empty
74287428
{
74297429
std::vector<int> v;
7430-
7431-
//NEW way in C++11
7432-
//initializer lists
7430+
//C++11 initializer lists:
74337431
std::vector<int> v1{};
7434-
74357432
assert(v == v1);
74367433
}
74377434

7438-
{
7439-
typedef std::vector<int>::size_type IndexType;
7440-
std::vector<IndexType> v;
7441-
v = std::vector<IndexType>(5);
7442-
v = std::vector<unsigned int>(4, 0);
7443-
7444-
}
7445-
74467435
/*
74477436
Fill constructor.
74487437

gtk/so.vim

-1
This file was deleted.

lapack/so.vim

-1
This file was deleted.
File renamed without changes.

plplot/so.vim

-1
This file was deleted.

so_individual.vim

-11
This file was deleted.

0 commit comments

Comments
 (0)