I was trying to set up vim to work with JavaScript (any links about that appreciated), though didn't even know what's .vimrc file. So I deleted it. After removing and installing vim for about 10 times... I now don't know what exactly should I do. I believe there was some default settings that I lost. If I google for it I find bunch of different vimrc files, and if I put their content in my vimrc - whenever I start vim I get a lot of errors (assuming because I don't have all the plug ins). also don't think that I should\can create one and fill it little by little.
so.
1. How do I restore my original vim state (if you think this is smtn I should do) - ?
2. How do I set it up to work nicely with JavaScript files?
3. Possibly good vim tutorial?
OS Ubuntu 12.04 32-bit
Thank you guys.
vim beginner.
If you hadn't customised the file at all before you started, then if it existed at all, it must have been the default for new users.
When creating a new user account, the files in /etc/skel are used to populate the new user's home directory; thus the file you deleted can probably be restored to its original state with the following command:
cp /etc/skel/.vimrc ~/.vimrc
That is "copy the .vimrc file from the skeleton directory into my home directory".
If that doesn't help, or if the file you deleted was actually the system-wide defaults (normally /etc/vimrc or /etc/vim/vimrc) then you can probably get hold of the original file from your OS's package archive.
Since you are running Ubuntu 12.04, the relevant file list seems to be this one: http://packages.ubuntu.com/precise/i386/vim-common/filelist It doesn't seem to put anything into /etc/skel, but it does install an /etc/vim/vimrc which includes /usr/share/vim/vimcurrent/debian.vim.
You can download the package manually from here - the .deb file is just a .tar.gz, so tar -xzvf foo.deb will extract it for you to poke around. cd to a new empty directory before doing that, or you'll get very confused by the directories it creates!
Another thing to double check is that Ubuntu actually has multiple different vim packages, e.g. vim-tiny. See this question for how to check you've installed and selected the "full" version.
A .vimrc file is optional, and without it vim will use all of its defaults.
These defaults, however, are a bit conservative. If I recall correctly, vim defaults to being compatible with its predecessor (vi), which means no syntax highlighting, no line numbers, no ruler to tell you which mode you're in, no nothing.
Tim Pope's sensible vimrc is a good point to start off.
.vimrc usually is a config file under your $HOME directory. Itself is a vimscript too. You can put your config/mapping/plugin config/function... there, so that everytime you started your vim, the file would be automatically loaded. then you have a customized comfortable editor opened.
without this .vimrc, vim can start too, with default config though.
you can start vim and type :h vimrc to see the help doc of vimrc. You can take a vimrc from internet, try to understand the settings in the file. finally make your own vimrc. It will take veryveryvery long time to have a satisifed vimrc. I have used vim for about 10 years, last week I was still editing my vimrc file.
When you read others' vimrc settings, use :h foo to find the help information. In this way, you know "why I set this", not "I don't know what's going on, just copied it".
The charm of vim is, it is highly customizable. You can change it into plain notepad or programming IDE or mp3 player...
enjoy editing!
Related
I want to edit some parts of a .js file, but when I open it by notepad++ and change those parts, my site doesn't load at all. I see some unknown character in that file and think this problem refers to them. Somehow when I open the file and change it, that file doesn't match what it should be. (maybe the author places them in the file in order to protect his/her work or maybe I don't know the appropriate editor!!)
I'll send the link of that file and hope you can guide me to solve this problem:
http://students.sbu.ac.ir/r.bastani/wp-content/themes/ceevee/js/plugins.js
Note
As #AndroidNoobie metioned, this is a bunch of minified libraries, so be very carefully, when you edit this file.
To make editing with notepad++ a bit easier, you should install the extension JSTool. You can install extensions by clicking on Extensions -> Plugin Manager -> Show Plugin Manager. Then search for JSTool.
When installed JSTool and opened that JS file, press CTRL + ALT + M. This will format the code, and it is much better readable.
Regarding to you question: When you execute this file with Google Chrome, open the DevTool (F12) and navigate to the Console tab. This will give you a better overview of what concrete characters are unknown.
The characters you mentioned in line 23 and 43 should not be unknown to JS (curly braces and commas). Maybe formatting the code helps you. If not, please provide more information about what is unknown.
EDIT
The files seems not to be loaded completely:
There are also some other errors in the console:
While I admit this is a pretty obscure problem, I'm posting this partly in case it is driving others crazy (too), partly because it might have wider ramifications, and partly because it may be an issue with my project settings.
In NB-8.1 I have several angular modules for handling a configuration-editing app. Since last week I have been trying to figure out why the navigator pane doesn't populate with these files. When I click on the source, the Navigator pane doesn't update. If the pane is newly opened, it shows <No view available>. If it is correctly showing another file, it remains showing the old file and effectively ignores the new file.
After experimenting, I found that it is specific to any js file with a filename prefix of "config" - which in this case was all the files for this particular app (config-service.js, config-ctrl.js, etc). Renaming the files with a new prefix (eg, "konfig-ctrl.js" or "x-config-ctrl.js") solved the issue.
Is this widespread, or a problem only with this project? If the latter, what should I look for? Help or advice appreciated.
This looks like a bug to me. AFAIK NetBeans is handling JS files with the config in name as possible Karma configurations and maybe it (although I can't remember if Karma has to be enabled or where exactly does it look for these candidate files...) I'd suggest to report a bug against NetBeans https://netbeans.org/bugzilla/enter_bug.cgi?product=web (component HTML Project)
I get a very similiar problem. Any js file with "conf" in the name (anywhere in the name) cannot be Run as javascript from Netbeans. Right-click on the file and Run is deactivated. Once I change the name to something else, it works.
I am having a problem with intellij IDE community edition 14.03 version that i hope you can help me,
when i modify a javascript file (an small change like a space) looks like intellij is changing the format or something behind scenes because when i check with svn tortoise in show differences as unified diff option looks like i was changing all my file, removing all the lines and the adding them again with the new change(the space that i added).
note: i was modifying the same file with webstorm IDE and when i select the same option(show differences as unified diff), this is just modifying the line that i change. i dont know if is something in my setting or a bug.
after checking this problenm with intellij team, in the bug
https://youtrack.jetbrains.com/issue/WEB-15304
We realize that the problem was due to .editorconfig file, we can work with .editconfig file to standarize the format of our files, doesn't matter what IDE are you working on, but in my case this file was getting my a headache, in my case the only thing that i need to do to solve my problem was remove does files in my project and everything is working fine now.
but i just wanna to mention that this file could solve a lot of our problems if our team work with differents IDEs
I am leaving the link about this if you are interested on it.
http://editorconfig.org/
Codekit only allows you to disable compilation of JS files on a per-file basis, but what's worse is it consistently reverts JS files I've already marked as no "compilation/output".
It happens when you open a JS file to edit it, or when you switch Git branches. You don't notice the change, Codekit does a background "refresh", and automatically updates your config.codekit. Next thing you know, you're saving the file, and Codekit is compiling a JS file you don't want.
I can work around by reverting changes to config.codekit, but in a large JS app, this is at best a poor workaround, and sitewide disabling of JS compilation should be an option.
If anyone passes by this question and still needs help, I will give some answers I found which solved the problem for me.
First, you can edit file-processing settings project-wide. In the project settings, it is possible to apply an output parameter to all existing files with the "Apply" button:
Then, you have an option to pause file-watching with a simple shortcut that works across the whole system. It is useful to avoid unwanted changed made to CodeKit's config file when switching branch in Git.
You can find more details about it in the CodeKit online documentation:
Using CodeKit With Git or Subversion
Before you perform any action that will change large numbers of files at once (switching branches, rebasing, pull requests, etc.) you MUST tell CodeKit to ignore file changes.
I've got a painfully simple jQuery plugin that I've written and placed on github. I am using Github for Windows and the website itself to manage the project.
Unfortunately, if I try to include any of the .js or .css files that I've uploaded there, through the Raw links, it fails in my browser due to the MIME-type being plain/text.
So, for the last couple of hours I've been researching how to get a copy of the files, through github, that people (including myself) can link to. The first step seems to be creating a project page (gh-pages branch)... that much I have grasped.
However, all of the material I've found so far either expects you to have a UNIX-based system, or do some console-based trickery:
Examples: GitHub, SO, SO
Now, there must be a straightforward way to simply make these source files available for inclusion. I went through the automated steps of creating a 'project page' and now I'm presented with another branch that is claiming to be behind the 'master' branch, but I can't see what I'm supposed to do next. It's not even clear to me why on earth I'm required to make another branch. This whole thing seems far more complicated than it needs to be.
So, to recap:
I've created a branch in Github (using Windows app and website)
I can manage that, and update my files, without incident
I am unable to include the .js and .css files using a 'raw' links
I want to be able to include those files in a page
I'd like to do this through Github for Windows, or on the site itself
If anyone could help walk me through this, I'd appreciate it. Also, I'd expect that A LOT of others would as well.
EDIT: Here is an example of a well-known Github project that has its files available through Github:
Select2:
http://ivaynberg.github.io/select2/select2-3.4.2/select2.js
EDIT2: Okay, conceptually, I now understand why I have to create a separate branch, in order to share the files - as the source control aspects of Github aren't meant to act as a CDN, the project page simply provides a public website where you can place your files. So the question now becomes: How do I put my files from the master branch into the gh-pages branch? I'm not worried about automating it or anything right now, all I want is access to the directory structure so I can place files in there. I've tried syncing and re-syncing my branch with Github Windows, but it tells me that there's nothing to get from the gh-pages branch, even though it's "10 commits behind". What is going on?
EDIT3: Added my own answer, for what I've come up with (so far).
As mentioned, there's lots of information out there for people who are using console-based Git software. However, I could not find a single piece of info on how to do this solely through Github Windows. Well, here is the solution:
Process:
Create a project page, as described here: https://help.github.com/articles/creating-pages-with-the-automatic-generator
Unfortunately, they only have console-based solution for getting a local copy. So here's how the rest of this works in Github Windows... (assumption: project name is myproject, consisting of myproject.js and myproject.css)
After the page has been created (takes a few minutes), open up Github Windows.
In Github Windows, open the repository for the project. On the top menubar it has "in sync", "master", "tools". Click on "master" and switch to "gh-pages" branch - SO example.
When you do this, the folder C:\Users\YourName\Documents\GitHub\myproject will now display the files for the "gh-pages" branch. If you click "master", in Github Windows, it will change the folder structure to once again represent the "master" branch. This is what confused me earlier, you can't see the directory structure for both branches at the same time.
Select the "master" branch in Github Windows.
In Windows Explorer, copy myproject.js and myproject.css into a separate directory (e.g., c:\temp).
Go back to Github Windows and select the "gh-pages" branch.
Go back to Windows Explorer and cut the files you put into c:\temp and paste them into a directory like C:\Users\YourName\Documents\GitHub\myproject\myproject-1.0\
Go back to Github Windows, and you'll see "2 files to be commited". Type in your commit message and click 'Commit'.
Then click 'Sync'.
You can now include these files in your webpages, using a URL like: http://yourname.github.io/myproject/myproject-1.0/myproject.js
Obviously this is a huge pain in the ass to do it this way, if you expect to be updating the source file(s) regularly. So obviously an automated approach would be most ideal. There is an answer for this on SO here, unfortunately it involves UNIX-based scripting which I have zero knowledge of (and, truthfully, no interest in learning just for this). If anyone comes up with a more efficient way of doing this, using only the GUI-based tools, I'm sure myself and many others would be interested in hearing about it.
EDIT: This solution is obviously usurping Github's intended way of doing things, as when I click on the "gh-pages" branch on the github website it tells me that it's "5 commits ahead and 11 commits behind" the master branch, even though they have the same files. So, again, if anyone else has a better GUI-based solution to this problem, I'm all ears.
Git(hub) software for Windows is the buggiest thing I've ever used (well, besides Windows itself). Back when I used Windows, I could hardly get anything to work with Git at all.
But, anyways, to answer your question, if you open a command prompt and type in
git checkout -b gh-pages
(if it complains about branch gh-pages already existing, remove the -b.)
it should switch the branch. Then, you can launch notepad++ or whatever text editor you use (you might have to do it from the terminal, I can't remember), add the file you want, and then type in (in cmd):
git add .
This recursively adds all files in the folder to Git.
git commit -m "Add file for easy user download"
This adds the commit message.
git remote add origin git#github.com:yourusername/yourrepository.git
This adds the Github repo so you can push to it
git push origin gh-pages
This pushes your changes to Github.
And, you're all set!
You might want to read this on Git branching.