Questions tagged [camelcasing]
Camel case is a language-independent naming convention in which an identifier name will start with a lowercase letter and each additional word within the name will start uppercase, such as customerName, printInvoice, etc.
camelcasing
420
questions
1083
votes
15
answers
805k
views
What is the naming convention in Python for variables and functions?
Coming from a C# background the naming convention for variables and methods are usually either camelCase or PascalCase:
// C# example
string thisIsMyVariable = "a"
public void ThisIsMyMethod(...
640
votes
7
answers
582k
views
JSON Naming Convention (snake_case, camelCase or PascalCase) [closed]
Is there a standard on JSON naming?I see most examples using all lower case separated by underscore, aka snake_case, but can it be used PascalCase or camelCase as well?
355
votes
11
answers
164k
views
Acronyms in CamelCase [closed]
I have a doubt about CamelCase. Suppose you have this acronym: Unesco = United Nations Educational, Scientific and Cultural Organization.
You should write: ...
332
votes
29
answers
369k
views
Elegant Python function to convert CamelCase to snake_case?
Example:
>>> convert('CamelCase')
'camel_case'
324
votes
14
answers
227k
views
How can I return camelCase JSON serialized by JSON.NET from ASP.NET MVC controller methods?
My problem is that I wish to return camelCased (as opposed to the standard PascalCase) JSON data via ActionResults from ASP.NET MVC controller methods, serialized by JSON.NET.
As an example consider ...
298
votes
45
answers
666k
views
Converting a string with spaces into camel case
How can I convert a string into camel case using javascript regex?
EquipmentClass name or
Equipment className or equipment class name or Equipment Class Name
should all become: equipmentClassName.
271
votes
3
answers
23k
views
How to navigate through the source code by parts in CamelCase (instead of whole words)?
I remember when I was using Eclipse that when holding CTRL and using left or right arrows Eclipse would navigate over the LongCamelCaseWrittenWord in several steps. One camel case word at time.
So it ...
170
votes
16
answers
94k
views
Convert hyphens to camel case (camelCase)
With regex (i assume) or some other method, how can i convert things like:
marker-image or my-example-setting to markerImage or myExampleSetting.
I was thinking about just splitting by - then ...
142
votes
6
answers
76k
views
What are the different kinds of cases?
I'm interested in the different kinds of identifier cases, and what people call them. Do you know of any additions to this list, or other alternative names?
myIdentifier : Camel case (e.g. in java ...
137
votes
4
answers
71k
views
Convert JSON style properties names to Java CamelCase names with GSON
I'm using GSON to convert JSON data I get to a Java object. It works pretty well in all my tests.
The problem is that our real objects have some properties named like is_online. GSON only maps them if ...
128
votes
6
answers
135k
views
Should Python class filenames also be camelCased?
I know that classes in Python are typically cased using camelCase.
Is it also the normal convention to have the file that contains the class also be camelCase'd especially if the file only contains ...
120
votes
16
answers
84k
views
Converting Snake Case to Lower Camel Case (lowerCamelCase)
What would be a good way to convert from snake case (my_string) to lower camel case (myString) in Python 2.7?
The obvious solution is to split by underscore, capitalize each word except the first one ...
111
votes
19
answers
187k
views
Convert String To camelCase from TitleCase C#
I have a string that I converted to a TextInfo.ToTitleCase and removed the underscores and joined the string together. Now I need to change the first and only the first character in the string to ...
95
votes
11
answers
68k
views
RegEx to split camelCase or TitleCase (advanced)
I found a brilliant RegEx to extract the part of a camelCase or TitleCase expression.
(?<!^)(?=[A-Z])
It works as expected:
value -> value
camelValue -> camel / Value
TitleValue -> Title / ...
95
votes
4
answers
35k
views
Why True/False is capitalized in Python?
All members are camel case, right? Why True/False but not true/false, which is more relaxed?
83
votes
9
answers
110k
views
Disable check of camel case rule in eslint
I have a large JavaScript file with multiple eslint rule violations. I am trying to disable them and address them one at a time. The code below shows that I can disable them all with no trouble, but ...
79
votes
3
answers
48k
views
Underscores or camelCase in PostgreSQL identifiers, when the programming language uses camelCase? [closed]
Given an OO language in which the naming convention for object properties is camelCased, and an example object like this:
{
id: 667,
firstName: "Vladimir",
lastName: "...
76
votes
16
answers
45k
views
How to do CamelCase split in python
What I was trying to achieve, was something like this:
>>> camel_case_split("CamelCaseXYZ")
['Camel', 'Case', 'XYZ']
>>> camel_case_split("XYZCamelCase")
['XYZ', '...
56
votes
5
answers
19k
views
Javascript/jQuery: Split camelcase string and add hyphen rather than space
I would imagine this is a multiple part situation with regex, but how would you split a camelcase string at the capital letters turning them in to lowercase letters, and then adding a hyphen between ...
51
votes
9
answers
64k
views
Regex for PascalCased words (aka camelCased with leading uppercase letter)
How do I find all PascalCased words in a document with a regular expression?
If you don't know the word Pascal cased, I'm only concerned with leading Upper camel case (i.e., camel cased words in ...
47
votes
4
answers
39k
views
Can I use camelCase in CSS class names
I want to name a CSS class and call it imgSuper. Can I use camelCasing in CSS classes?
42
votes
5
answers
8k
views
Is there a way to enable camel humping through method names in VS Code?
As this question is for the "big" Visual Studio and Resharper, I'd like to see that feature in VS Code too.
Scrolling through the shortcut list for VS Code, I couldn't find it but I'm hoping that it'...
40
votes
7
answers
37k
views
Converting nested hash keys from CamelCase to snake_case in Ruby
I'm trying to build an API wrapper gem, and having issues with converting hash keys to a more Rubyish format from the JSON the API returns.
The JSON contains multiple layers of nesting, both Hashes ...
40
votes
5
answers
14k
views
Naming convention for upper case abbreviations [closed]
Should a method that returns an XML stream be called
public Stream getXmlStream();
or instead
public Stream getXMLStream();
What's your opinion about that? What's considered best practice?
38
votes
2
answers
32k
views
MVC JsonResult camelCase serialization [duplicate]
I am trying to make my action return a JsonResult where all its properties are in camelCase.
I have a simply model:
public class MyModel
{
public int SomeInteger { get; set; }
public ...
37
votes
8
answers
55k
views
Default camel case of property names in JSON serialization
I have a bunch of classes that will be serialized to JSON at some point and for the sake of following both C# conventions on the back-end and JavaScript conventions on the front-end, I've been ...
37
votes
6
answers
59k
views
Is using camelCase in CSS ids or classes ok or not?
Question is in the title. I'm used to using camelcase in development and, since there are crossovers with design, was wondering if there are any technical reasons (regardless of opinions) against ...
36
votes
5
answers
25k
views
Convert kebab-case to camelCase with JavaScript
Say I have a function that transforms kebab-case to camelCase:
camelize("my-kebab-string") === 'myKebabString';
I'm almost there, but my code outputs the first letter with uppercase too:
...
36
votes
6
answers
9k
views
Acronyms in Camel Back
I often see Java class names like
XmlReader
instead of
XMLReader
My gut feeling is to completely upper case acronyms, but apparently many people think differently. Or maybe it's just because a lot ...
36
votes
3
answers
34k
views
When should I use camelCase / Camel Case or underscores in PHP naming?
I've been learning PHP and see there is a lot of variability in how people name stuff. I am keen to at least be consistent with myself.
Where should I be using Camel Case and where should I be using ...
35
votes
7
answers
13k
views
Converting from camelcase to _ in emacs
Is there an emacs function to convert a camel-cased word to underscore? Something, like:
longVariableName
M-x to-underscore
long_variable_name
35
votes
14
answers
17k
views
Separating CamelCase string into space-separated words in Swift
I would like to separate a CamelCase string into space-separated words in a new string. Here is what I have so far:
var camelCaps: String {
guard self.count > 0 else { return self }
var ...
35
votes
4
answers
12k
views
Force CamelCase on ASP.NET WebAPI Per Controller
In ASP.NET WebAPI, I know you can set the default json formatter to use camel case using CamelCasePropertyNamesContractResolver() in the global.aspx which will force ALL json serialization to camel ...
30
votes
8
answers
24k
views
How to convert a camel-case string to dashes in JavaScript?
I want to convert these strings:
fooBar
FooBar
into:
foo-bar
-foo-bar
How would I do this in JavaScript the most elegant and performant way for any given string?
29
votes
2
answers
20k
views
Convert CamelCase to under_score_case in php __autoload()
PHP manual suggests to autoload classes like
function __autoload($class_name){
require_once("some_dir/".$class_name.".php");
}
and this approach works fine to load class FooClass saved in the file ...
29
votes
6
answers
10k
views
How to convert not.camel.case to CamelCase in R
In R, I want to convert
t1 <- c('this.text', 'next.text')
"this.text" "next.text"
to
'ThisText' 'NextText'
I have tried
gsub('\\..', '', t1)
But this gives me
"thisext" "nextext"
as it ...
29
votes
4
answers
31k
views
How can I convert from underscores to camel case with a regex?
How can I convert names with underscores into camel case names as follows using a single Java/Perl regular expression search and replace?
underscore_variable_name -> underscoreVariableName
...
23
votes
9
answers
18k
views
linux bash, camel case string to separate by dash
Is there a way to convert something like this:
MyDirectoryFileLine
to
my-directory-file-line
I found some ways to convert all letters to uppercase or lowercase, but not in that way; any ideas?
22
votes
10
answers
8k
views
For what reason do we have the lower_case_with_underscores naming convention? [closed]
Depending on your interpretation this may or may not be a rhetorical question, but it really baffles me. What sense does this convention make? I understand naming conventions don't necessarily have to ...
22
votes
4
answers
134k
views
Convert a String to Modified Camel Case in Java or Title Case as is otherwise called [duplicate]
I want to convert any string to modified Camel case or Title case using some predefined libraries than writing my own functions.
For example "HI tHiS is SomE Statement" to "Hi This Is Some Statement"...
22
votes
5
answers
20k
views
Awk/sed script to convert a file from camelCase to underscores
I want to convert several files in a project from camelCase to underscore_case.
I would like to have a onliner that only needs the filename to work.
22
votes
1
answer
9k
views
Single letter words in camelCase, what is a standard for handling these?
I'm trying to group together an object's vertex X components in a vector, like structure of array style.
Naturally this is the way.
Vec xComponents; or Vec xVals; or simply Vec x;
However ...
21
votes
2
answers
25k
views
All text from camelCase to SNAKE_CASE
I am trying to do some text manipulations using Notepad++ macros. My last step is converting camelCase strings to SNAKE_CASE. So far no luck. I'm not very familiar with regex so can't write my own ...
21
votes
1
answer
3k
views
Camel casing hyphenated English words (e.g. re-render)
Typically if you're converting a string of words to camel case you capitalise only the first letter of every word (bar the first word).
How does this apply to hyphenated words like re-render?
...
20
votes
2
answers
3k
views
When syncing with an underscored backend, convert to CamelCase for use in JavaScript?
TL/DR: What's a good way to use an underscored naming convention serverside (RoR) with a camelCased naming convention clientside (JS)
Server-side programming environments like Ruby on Rails use ...
20
votes
2
answers
8k
views
Changing parts of CamelCase words in vim
Using vim, I find cw very handy for changing an entire word. Vim's separation of motion commands and action verbs makes for very powerful combinations. I just now had to change DefaultHandler to ...
18
votes
4
answers
10k
views
camelCase to dash - two capitals next to each other
I'm using this function to convert CamelCase to dashed string:
function camel2dashed($className) {
return strtolower(preg_replace('/([^A-Z-])([A-Z])/', '$1-$2', $className));
}
it kinda works ...
17
votes
1
answer
5k
views
How to disable camel case selection in Eclipse
Is it possible to disable support for camel case in the Eclipse text editor? I want the next word key binding to select the next word, not the next fragment of a word.
I'd given up on eclipse because ...
16
votes
2
answers
11k
views
How to parse Camel Case to human readable string?
Is it possible to parse camel case string in to something more readable.
for example:
LocalBusiness = Local Business
CivicStructureBuilding = Civic Structure Building
getUserMobilePhoneNumber = Get ...
16
votes
2
answers
25k
views
TypeScript - Use PascalCasing or camelCasing for module names?
I'm wondering if I should use PascalCasing or camelCasing for my modules names, so far I've always used PascalCasing, i.e: Ayolan.Engine.Rendering instead of Ayolan.engine.rendering (I keep ...