summaryrefslogtreecommitdiffstats
path: root/vim/fun.vim
diff options
context:
space:
mode:
authormitsuo <[email protected]>2021-11-22 05:36:18 -0500
committermitsuo <[email protected]>2021-11-22 05:36:18 -0500
commit33bfafb50ea8a9842cb41e599f487e3ee0146618 (patch)
tree55e84cde487ccb894f7203d33a078fb2aa8cad4c /vim/fun.vim
parentf13815efce733d23ba7dc1003d0decde09fccd4c (diff)
downloaddotfiles-33bfafb50ea8a9842cb41e599f487e3ee0146618.tar.gz
dotfiles-33bfafb50ea8a9842cb41e599f487e3ee0146618.tar.bz2
dotfiles-33bfafb50ea8a9842cb41e599f487e3ee0146618.zip
Restructure directory, Fix install.sh
Diffstat (limited to 'vim/fun.vim')
-rw-r--r--vim/fun.vim83
1 files changed, 83 insertions, 0 deletions
diff --git a/vim/fun.vim b/vim/fun.vim
new file mode 100644
index 0000000..0dbfe11
--- /dev/null
+++ b/vim/fun.vim
@@ -0,0 +1,83 @@
+" Echoes longest line number and lenght.
+
+function! LongestLineLength ( )
+ let maxlength = 0
+ let linenumber= 1
+ while linenumber <= line("$")
+ exe ":".linenumber
+ let linelength = virtcol("$")
+ if maxlength < linelength
+ let maxlength = linelength
+ let maxlinenumber = linenumber
+ endif
+ let linenumber = linenumber+1
+ endwhile
+
+"exe ':0'
+"exe 'normal O'
+"exe 'normal 0C'.maxlength
+ exe "normal" . maxlinenumber . "G"
+ exe ":echo \"" . maxlinenumber . ": " . maxlength . "\""
+endfunction
+
+command LongestLineLength call LongestLineLength()
+
+
+" Save markdown document and export to pdf using pandoc.
+"
+" It would be nicer if a default document would be used but I coulnd't made it
+" to work even after reading that manual section like 2 times. Also, there are
+" variables that are lists of other variables that I don't know how to make them
+" work (e.g. geometry=[top=1in, bottom=1in, heightrounded])
+
+function! Md2Pdf ( )
+ exe ":w"
+ "-N for numbered headers
+ exe ":! pandoc -o \"" . expand("%:r") . ".pdf\" -t latex --variable classoption=twosides --variable papersize=a4 --variable margin-left=1in --variable margin-right=1in --variable margin-top=1in --variable margin-bottom=1in --variable links-as-notes --variable colorlinks --variable pagestyle=plain --variable documentclass=article -f markdown-implicit_figures \"" . expand("%") . "\""
+ echo "pdf saved as \"" . expand("%:p:r") . ".pdf\""
+endfunction
+
+function! Md2Pdfms ( )
+ exe ":w"
+ exe ":! pandoc -o " . expand("%:r") . ".pdf" . " -t ms -f markdown-implicit_figures \"" . expand("%") . "\""
+ echo "pdf saved as " . expand("%:p:r") . ".pdf"
+endfunction
+
+command Md2Pdf call Md2Pdf()
+command Md2Pdfms call Md2Pdfms()
+
+
+" Save markdown document and export to html using pandoc
+
+function! Md2Html ( )
+ exe ":w"
+ exe ":! pandoc -o \"" . expand("%:r") . ".html\"" . " -s \"" . expand("%") . "\""
+ echo "html saved as " . expand("%:p:r") . ".html"
+endfunction
+
+command Md2Html call Md2Html()
+
+" Compiles and Runs a C++ project
+
+" TODO: how to add program's arguments or file redirectioning from command.
+function! CompRunProj ( )
+ exe ":w"
+ exe ":! g++ -o " . expand("%:r") . "-g *.cpp"
+ exe ":! ./" . expand("%:r")
+endfunction
+
+command CompRunProj call CompRunProj()
+
+
+" Function made to give feedback to students code in 1INF01
+
+" export C code to syntax highlighted pdf
+function! C2Pdf ( )
+ exe ":set ts=4"
+ exe ":w"
+ exe ":ha > %.ps"
+ exe ":!ps2pdf %.ps"
+ exe ":!rm %.ps"
+endfunction
+
+command C2Pdf call C2Pdf()