Skip to main content

Questions tagged [caret]

Caret refers to an onscreen text-cursor. For the R package, use the [r-caret] tag. For the ASCII character, use the [punctuation] tag.

Filter by
Sorted by
Tagged with
5393 votes
22 answers
1.9m views

What's the difference between tilde(~) and caret(^) in package.json?

After I upgraded to the latest stable node and npm, I tried npm install moment --save. It saves the entry in the package.json with the caret ^ prefix. Previously, it was a tilde ~ prefix. Why are ...
Fizer Khan's user avatar
  • 91.3k
395 votes
8 answers
409k views

How to get the focused element with jQuery?

Using jQuery, how can I get the input element that has the caret's (cursor's) focus? Or in other words, how to determine if an input has the caret's focus?
dave's user avatar
  • 15.3k
299 votes
13 answers
254k views

How to set the caret (cursor) position in a contenteditable element (div)?

I have this simple HTML as an example: <div id="editable" contenteditable="true"> text text text<br> text text text<br> text text text<br> </div>...
Frodik's user avatar
  • 15.3k
191 votes
18 answers
192k views

Get contentEditable caret position

I'm finding tons of good, cross-browser answers on how to set the caret position in a contentEditable element, but none on how to get the caret position in the first place. What I want to do is know ...
Bertvan's user avatar
  • 5,003
179 votes
4 answers
170k views

How to get the caret column (not pixels) position in a textarea, in characters, from the start?

How do you get the caret position in a <textarea> using JavaScript? For example: This is| a text This should return 7. How would you get it to return the strings surrounding the cursor / ...
Restless Wanderer's user avatar
176 votes
5 answers
142k views

What does the caret (^) operator do?

I ran across the caret operator in python today and trying it out, I got the following output: >>> 8^3 11 >>> 8^4 12 >>> 8^1 9 >>> 8^0 8 >>> 7^1 6 >>...
Fry's user avatar
  • 4,216
140 votes
9 answers
170k views

Styling text input caret

I want to style the caret of a focused <input type='text'/>. Specifically, the color and thickness.
Randomblue's user avatar
  • 115k
132 votes
4 answers
75k views

contenteditable, set caret at the end of the text (cross-browser)

output in Chrome: <div id="content" contenteditable="true" style="border:1px solid #000;width:500px;height:40px;"> hey <div>what's up?</div> <div> <button id="...
user avatar
97 votes
2 answers
82k views

Carets in Regular Expressions

Specifically when does ^ mean "match start" and when does it mean "not the following" in regular expressions? From the Wikipedia article and other references, I've concluded it means the former at ...
Sylvester V Lowell's user avatar
88 votes
11 answers
103k views

Set the caret/cursor position to the end of the string value WPF textbox

I am try to set the caret/cursor position to the end of the string value in my WPF textbox when I open my window for the first time. I use the FocusManager to set the focus on my textbox when my ...
Zamboni's user avatar
  • 8,005
72 votes
6 answers
120k views

Get caret position in HTML input?

How do I get the index of the text caret in an input?
user avatar
68 votes
11 answers
43k views

Placeholder in contenteditable - focus event issue

I have been trying to ask this before, without any luck of explaining/proving a working example where the bug happens. So here is another try: I’m trying to replicate a placeholder effect on a ...
David Hellsing's user avatar
62 votes
11 answers
106k views

Hide textfield blinking caret

I have a text input in my HTML. Is there a way to hide the blinking text caret when the input gets focus? I am open to doing this with JavaScript or CSS.
test's user avatar
  • 18.1k
45 votes
7 answers
79k views

Remove text caret/pointer from focused readonly input

I am using an <input readonly="readonly">, styled as normal text to remove the appearance of an interactive field, but still display the value. This is very useful to prevent a user from ...
Mog's user avatar
  • 102k
38 votes
1 answer
19k views

Get element node at caret position (in contentEditable)

Let's say I have some HTML code like this: <body contentEditable="true"> <h1>Some heading text here</h1> <p>Some text here</p> </body> Now the caret (the ...
Lucas's user avatar
  • 6,338
37 votes
2 answers
8k views

Clojure caret as a symbol?

So I thought it would be a nice idea to name a function that calculates the exponential ^, but it seems like the caret actually does something special, as the Clojure REPL generates an error when ...
wrongusername's user avatar
36 votes
6 answers
65k views

jquery Setting cursor position in contenteditable div

The old version of the question is below, after researching more, I decided to rephrase the question. The problem as before is, I need to focus a contenteditable div without highlighting the text, ...
Mark's user avatar
  • 33.1k
34 votes
4 answers
14k views

SwiftUI TextField cursor colour

Currently the cursor/caret for my SwiftUI TextField is blue. Is there an API for cursor colour or a workaround?
SnoopDogg's user avatar
  • 481
31 votes
3 answers
11k views

How do I change the current line highlight background in PyCharm?

The question says it all. I need the place to style the current line highlight.
notbad.jpeg's user avatar
  • 3,348
28 votes
2 answers
26k views

TextBox Caret Styling

I've found a few things on setting CaretBrushes in WPF4, but has anybody actually ever changed the caret itself? What I'd like to do is use the OVERWRITE caret in INSERT mode. I've seen a hack from ....
Sebastian Edelmeier's user avatar
27 votes
1 answer
9k views

Use of caret symbol (^) in Ruby

1 ^ 1 # => 0 1 ^ 2 # => 3 5 ^ 6 # => 3 These are the results I am getting. Can, please, somebody explain how ^ works?
shajin's user avatar
  • 3,268
27 votes
6 answers
9k views

Caret position in pixels in an input type text (not a textarea) [duplicate]

UPDATE: duplicate of Get cursor or text position in pixels for input element. TL; DR - use the incredibly lightweight and robust textarea-caret-position Component library, which now supports <...
27 votes
2 answers
6k views

Vue.js v-html contenteditable prevent dom refresh to keep cursor / caret from jumping

For reference I'm using Vue 2.0, Vuex, and Firebase. I am building a contenteditable component using the v-html binding to render the innerHTML. The data is updated onKeyUp. Whenever the data is ...
Jason's user avatar
  • 565
23 votes
3 answers
28k views

twitter bootstrap issue : Right align the caret in the dropdown header

I have an issue with the right alignment of the caret. Using .pull-right in the span makes it go to the top right corner. How can I make it vertically centered again ? I also would like to align the ...
Franckl's user avatar
  • 1,461
22 votes
7 answers
69k views

Changing bootstrap caret(color and position)

I want to change color of caret and make it not relative from input text, because it's hard to make it look good when it is.
Denys Medynskyi's user avatar
22 votes
1 answer
27k views

Set caret position at a specific position in contenteditable div

SEE BEFORE MARKING DUPLICATE/DOWNVOTING The contenteditable div will not have child elements I do not want to set the position at the end of the div I do not want a cross-browser solution, only ...
Gaurang Tandon's user avatar
22 votes
2 answers
5k views

Caret position reverts to start of contenteditable span on re-render in React in Safari and Firefox

When typing text into a contenteditable span in Safari or Firefox the caret moves to the start on each keypress. This only seems to happen when React re/renders the component. Chrome works just fine. ...
Damian's user avatar
  • 229
20 votes
1 answer
23k views

Javascript: Move caret to last character

I have a textarea and when I click in it I want to move the caret to the last character so Something[caret] function moveCaret(){ // Move caret to the last character } <textarea onclick="...
Adam Halasz's user avatar
  • 58.1k
20 votes
10 answers
19k views

Mobile Safari - Input caret does not scroll along with overflow-scrolling: touch

I know that Mobile Safari won't fire events while in "momentum" (-webkit-overflow-scrolling: touch;) scrolling. But this is not entirely the same thing, because Safari handles the (blinking) caret of ...
gabrielmaldi's user avatar
  • 2,196
19 votes
3 answers
13k views

JavaScript get word before cursor

Okay, I've been looking all over the web to find a solution but I couldn't find one, is there a way to get the word before the caret position in an editable div so a bit like: This is some| demo ...
Lennart's user avatar
  • 1,560
19 votes
1 answer
6k views

RewriteRule ^ - [L] AKA RewriteRule caret dash L

While I could turn on Rewrite Logging and mess with this rule to figure out what it does (if anything), I bet someone already knows. Here's the rule by itself: RewriteRule ^ - [L] Here it is in ...
Dave Scotese's user avatar
18 votes
2 answers
17k views

How do you match a caret (^) symbol in regex?

I know these won't do it and also why, but how do you match it? /^/ /(^)/ /[^]/
Tyilo's user avatar
  • 29.8k
18 votes
4 answers
9k views

Get caret coordinates on a contenteditable div through javascript.

I've been searching a lot but i could't find a way to get (X,Y) coordinates for the caret on a content editable div,there's a lot of content on the web about this,but the problem none of the pages i ...
Mateus's user avatar
  • 2,668
17 votes
2 answers
7k views

javascript – execute when textarea caret is moved

I have textarea and I want to change text that says what character is after the caret (cursor). <textarea id="text"></textarea> <br/> Character after the caret: <span id="char"&...
jiwopene's user avatar
  • 3,501
15 votes
1 answer
12k views

get last character before caret position in javascript

I am about to implement Facebook like in integration in my contenteditable div where if i give '$' and some character like 'a' i need a auto-suggestion which should pop up near my caret position. I ...
Anoop's user avatar
  • 859
15 votes
3 answers
11k views

How do I get window.getselection to work for an input type=text field

I have a contenteditable div, like so: <div id="test" contentEditable="true" style="width: 600px; height:300px;">Lorem ipsum dolor sit amet</div> for which I use the following code: <...
Freakishly's user avatar
  • 1,551
15 votes
1 answer
15k views

Auto text scroll for text area (JTextArea) with caret position set to the beginning of the last line

I have a simple Java question here. I want to auto text scroll to the beginning of the last line of a text area created using JTextArea. The amount of text per line of the text area is quite longer ...
SSaikia_JtheRocker's user avatar
15 votes
1 answer
1k views

Accounting for `<br>`s in contenteditable caret position

To get and set the caret position in an contenteditable element, I've tried the code from this answer, but the start & end position resets as you move into different text nodes. <div ...
Mottie's user avatar
  • 85.9k
13 votes
1 answer
37k views

Move the cursor position with Javascript?

I'm looking to move the caret exactly four spaces ahead of its current position so that I can insert a tab properly. I've already got the HTML insertion at the caret's position working, but when I ...
Elliot Bonneville's user avatar
13 votes
4 answers
4k views

How to have transparent fonts except for the 'text-caret' in a textarea?

I have a simple textarea and I need to make transparent letters while allowing the text-caret to be visible. When I apply the following rules then I get invisible caret: textarea { background: ...
Erik's user avatar
  • 14.5k
13 votes
2 answers
21k views

How to avoid cmd.exe interpreting shell special characters like < > ^

I have a Windows CMD script that accepts a number of parameters and executes an EXE, passing first some hard-coded arguments and then all of the parameters from the user. The CMD script looks like ...
Paul Urban's user avatar
12 votes
3 answers
2k views

Place caret back where it was after changing innerHTML of a contenteditable element

I need to update the innerHTML of a contenteditable P element after each keystroke, in JavaScript (no jQuery) I can't use an input or textarea instead of the P element. It works fine, but the ...
xem's user avatar
  • 330
11 votes
3 answers
18k views

Java: column number and line number of cursor's current position

I want to know the column number and row number where the cursor in JTextArea. ie. in notepad when i m at first line than status bar shows Ln 1, Col 1. thanks in advance...
Harry's user avatar
  • 137
11 votes
5 answers
13k views

Custom Caret for WinForms TextBox

I'm developing a custom HyperTerminal like application in a WinForms .Net 2.0 application. I have a multiline TextBox in a Panel in which you can interact with a hardware device. My customer wants ...
Rogier's user avatar
  • 1,210
11 votes
6 answers
3k views

Why 10^1 is 11?

I am currently learning C++. I was trying to compute power of an integer using the expression: val=10^1; Instead of expected answer 10, the result was 11. I have fixed the problem by using pow ...
user avatar
11 votes
1 answer
22k views

Set the caret position always to end in contenteditable div [duplicate]

In my project, I am trying to set the caret position always to the end of the text. I know this is default behaviour but when we add some text dynamically, then the caret position changes to starting ...
Mr_Green's user avatar
  • 41.4k
11 votes
1 answer
5k views

how to get the caret position of a contenteditable div which contains images

I have this contentedittable div <div contenteditable="true" id="text">minubyv<img src="images/smiley/Emoji Smiley-01.png" class="emojiText" />iubyvt</div> Here is an image ...
doggie brezy's user avatar
10 votes
4 answers
10k views

Java - Scroll to specific text inside JTextArea

I'm trying to implement a feature inside the current program that I'm writing and I wanna learn how to scroll down to specific text inside a JTextArea. For example, lets say I have the following: ...
Josh M's user avatar
  • 11.9k
10 votes
2 answers
9k views

How to move caret to start or middle of a line in PyCharm

If you hit the End key on your keyboard in PyCharm, the caret moves to the end of the line. Is there any key for going to the start or middle of a line in PyCharm? If you press Ctrl+G, it asks you to ...
python's user avatar
  • 4,481
10 votes
4 answers
845 views

Preprocessor macro using caret ^ symbol at the start of an expression

Looking at this page: http://www.mikeash.com/pyblog/friday-qa-2010-12-31-c-macro-tips-and-tricks.html I found this snippet of code with ^{ ... }() syntax, what are the caret/brackets doing? #define ...
pyramation's user avatar
  • 1,671

1
2 3 4 5
19