run command within Vim (but from a different directory) - vim

I would like to run pdflatex from within vim to update the pdf file I'm currently working editing, which is a chapter-xx.tex file. My main problem is that my chapter-xx.tex file is just an input file within my MASTER.tex file, which is in another directory.
I can try this:
:!pdflatex template/MASTER.tex
That does run pdflatex on my MASTER.tex file, which has my chapter-xx.tex file as an input file. However, pdflatex can't find my input files. I believe this is because my current working directory is that of the chapter-xx.tex file that I'm currently working on. The input file paths inside MASTER.tex file are all relative to it's own directory structure. From bash, where template/MASTER.tex resides, it has zero problems. But inside my chapter-xx.tex file, which is one directory down. ( ../) from MASTER.tex, it can't find the input other .tex files, which are input files within MASTER.tex
I believe the question I need to ask is how to change the current working directory then run the pdflatex command, while still working in my chapter-xx.tex file.
by the way, each chapter has actual numbers rather than "xx" by the way.
Also, pdflatex takes a text file (.tex) and converts it into a pdf file. A .tex file can also import other .tex files, which is my case. I have one MASTER.tex file, with numerous imports of other tex files, such as Chapters.

Related

How to print all the file paths inside of a folder from linux command line

I have a very simple question about the linux command line. Say I'm in a folder in the terminal with 6 CSV files. I'd like to simply print out the contents of the folder with all of the paths to the six files listed. I'd like to use these paths to these files in my code to access them. What command would do this?
Would it be a modified LS command? I'd like to not use the 'find' command.

Modify some text of a file in a zip file

On linux, I would like to modify a file that is inside a zip without having to extract it. The file is in any possible extension.
Here's an exemple.
test.zip
|---hello.someextension
|---bye.someextension
The file hello.someextension contains following text: Hello, this is a test.
What I would like to do
Modify the word test in the hello.someextension file to be "gift" instead, for instance.
Modifying the text is not really a big deal, but the issue I'm facing is that I cannot edit a file that is inside a .zip. I tried via VIM and here's an exemple output:
ÅÍ.PE¥&ö$kpì`w_OËŽ=“XÖ¸m† 86=šoÔRw«Õºxÿ¯Ûiö²X
Vim supports editing zipped files out-of-the-box. If it doesn't work for you then you have a local problem of some sort.
Check if it helps to bypass your faulty vimrc (e.g. vim -u NORC -N), or to re-install the whole Vim package etc.

Moves files from directory by reading file names from a text file

I want a script that is able to read the content of a text file which contains folder names and moves the folders from their directory to a specific folder. Here is my script:
#!/bin/bash
for i in $(cat /folder/collected/folders.txt)
do
mv /fromfilelocation/$i /folder/Collected/
done
This script is partly working as it copies only the last folder in the text file, as for the other folders it gives the error "not possible: data or directory not found" But the folder is there and according to the error the folder directory is correctly displayed.
The names do not have special characters or white spaces and if either way full directory or only folder name in the text file it is the same error.
The error that is displayed is cannot find file or directory but it display the correct directory to the folder with a '$'\r'. example /fromfilelocation/foldername'$'\r.
This is error due to line feed characters.. do dos2unix on the file with directory names then run the script again. there is nothing wrong with script

where is 'my.cnf' file in Linux?

I'm setting MariaDB with Linux up.
And I was going to edit property "bind-address" to accept external connection.
So I need to edit 'my.cnf' file. I found this file and tried to "vi my.cnf" and my linux shows
where can I find "bind_address" property and edit it?
Did i find right file?
From the last two lines in this file, you can see that it loads all the files in /etc/mysql/conf.d/ and /etc/mysql/mariadb.conf.d/. So you also have to look in those directories for a files that have a "bind-address" line.
You can look for "bind-address" automatically using the following command:
grep -r 'bind-address' /etc/mysql/conf.d/ /etc/mysql/mariadb.conf.d/
This command looks for lines containing "bind-address" in all the files in each directory, and for each matching line it will print the filename and the line. You can then edit the files that it finds using your favourite text editor.

No tags file in GVim on some file but not on others

I just installed ctags via homebrew and appended the following line in my ~/.vimrc:
set tags=./tags,tags;$HOME
And then I ran /usr/local/bin/ctags -R . on some of my directories and opened some files stored in the directories, then some of those scripts succeeded in importing tags file but others didn't.
For example, I opened up test.py on my Python workspace, which I already run the above command in, and then I tried to put Ctrl+] on my GVim, it looks like successfully imported the tags file.
I also opened up hello.go located in ~/go/src/github.com/user/hello, in which I already executed the above ctags command, successfully imported the tags file. However, my test.rb file, which I just put on the Go's directory in order to do test purpose, didn't import the tags file correctly.
Also, when I executed the ctags command on ~/another_go_workspace/src, and then opened up the file located in ~/another_go_workspace/src/hello/hello.go, then the file didn't import the tags file... However, since I appended set tags=./tags,tags;$HOME on my ~/.vimrc, doesn't it automatically look for higher directories, right?
So what am I missing?
And if it doesn't import the tags file in higher directories, do I have to execute the ctag command on EVERY directory, i.e. on ~/go/src/soccer_analysis, ~/go/src/coffee, ~/go/src/utility, etc, etc... ?
Thanks.
Your value for the tags option is correct and your assumptions about its behaviour are correct too.
With your setting, set tags=./tags,tags;$HOME, Vim will search for a tags file in the directory of the current file first then for a tags file from the working directory upward to $HOME.
This allows you to generate a tags file at the root of your project and be sure that Vim will pick it up wherever you are in your project and whatever the working directory is.
With the following structure and your current settings:
project/
bar/
bar.js
foo/
foo.js
project.js
tags
Vim should find tags in all the following scenarios and their variants:
$ vim project.js
$ cd foo && vim foo.js
$ cd bar && vim bar.js
$ vim foo/foo.js
$ vim bar/bar.js
$ cd bar && vim bar.js ../project.js
Every time you add a new file to your project or write to an existing file, you must re-index your whole project. From what you wrote about the ruby file, it looks like you didn't run ctags after adding the file. Try this for a selection of files in your project: :echo tagfiles().
No, vim doesn't go up directories to find tags files. I recommend you start vim from the top level directory (where you generated your tags), then traverse to whatever file you want.
vim go/src/coffee
Vim is capable of navigating filesystems nicely with commands like :Explore.
EDIT: I was wrong, semicolon can be used to search upwards. See :help file-searching
Also, I noticed that you tried to add $HOME to your tags, which isn't going to work for a number of reasons.
Documentation (:help 'tags') says:
Filenames for the tag command, separated by spaces or commas.
Therefore:
The delimiter is incorrect
$HOME is going to be treated like a tags file
So the "correct" way of doing this would be:
set tags=./tags,tags,$HOME/tags
Even if you do that though, I don't think it's going to work. Tags files comprise primarily of 2 elements, a search pattern and a filename. If you generated the file from the top, all filenames will be relative to that directory.
So if you are deep down in some subdir, vim will try to open the file using the relative filepath from the top, starting at that subdir.
The problem may have been caused by a typo. I think
set tags=./tags,tags;$HOME
should be
set tags=./tags;,tags;$HOME

Resources