Skip to main content
deleted 172 characters in body
Source Link
D. Ben Knoble
  • 27.7k
  • 3
  • 31
  • 68

In case I have the following line

// Component: <Component name here>                          |

where | is the cursor marker. How can I count, using vimscript, the total number of white spaces before the cursor until the first non space character (> in this case) ?

The aim is to delete all preceding whitespace before cursor, until non first space character (excluding it).

EDIT: I solved my doubt:

inoremap <silent> <expr> <nowait> <C-Backspace> col('.') == 1 ? "<Backspace>" : getline('.')[col('.') - 2] == ' ' ? "<C-o>diw" : "<C-o>db"

In case I have the following line

// Component: <Component name here>                          |

where | is the cursor marker. How can I count, using vimscript, the total number of white spaces before the cursor until the first non space character (> in this case) ?

The aim is to delete all preceding whitespace before cursor, until non first space character (excluding it).

EDIT: I solved my doubt:

inoremap <silent> <expr> <nowait> <C-Backspace> col('.') == 1 ? "<Backspace>" : getline('.')[col('.') - 2] == ' ' ? "<C-o>diw" : "<C-o>db"

In case I have the following line

// Component: <Component name here>                          |

where | is the cursor marker. How can I count, using vimscript, the total number of white spaces before the cursor until the first non space character (> in this case) ?

The aim is to delete all preceding whitespace before cursor, until non first space character (excluding it).

added 172 characters in body
Source Link
simzz
  • 510
  • 3
  • 12

In case I have the following line

// Component: <Component name here>                          |

where | is the cursor marker. How can I count, using vimscript, the total number of white spaces before the cursor until the first non space character (> in this case) ?

The aim is to delete all preceding whitespace before cursor, until non first space character (excluding it).

EDIT: I solved my doubt:

inoremap <silent> <expr> <nowait> <C-Backspace> col('.') == 1 ? "<Backspace>" : getline('.')[col('.') - 2] == ' ' ? "<C-o>diw" : "<C-o>db"

In case I have the following line

// Component: <Component name here>                          |

where | is the cursor marker. How can I count, using vimscript, the total number of white spaces before the cursor until the first non space character (> in this case) ?

The aim is to delete all preceding whitespace before cursor, until non first space character (excluding it).

In case I have the following line

// Component: <Component name here>                          |

where | is the cursor marker. How can I count, using vimscript, the total number of white spaces before the cursor until the first non space character (> in this case) ?

The aim is to delete all preceding whitespace before cursor, until non first space character (excluding it).

EDIT: I solved my doubt:

inoremap <silent> <expr> <nowait> <C-Backspace> col('.') == 1 ? "<Backspace>" : getline('.')[col('.') - 2] == ' ' ? "<C-o>diw" : "<C-o>db"

added 77 characters in body
Source Link
simzz
  • 510
  • 3
  • 12

In case I have the following line

// Component: <Component name here>                          $|

where $| is the end of linecursor marker (just for explanation purpose), how. How can I count, using vimscript, the total number of white spaces before the cursor until the first non space character (> in this case) ?

The aim is to delete all preceding whitespace before cursor, until non first space character (excluding it).

In case I have the following line

// Component: <Component name here>                          $

where $ is the end of line marker (just for explanation purpose), how can I count, using vimscript, the total number of white spaces before the cursor until the first non space character (> in this case) ?

In case I have the following line

// Component: <Component name here>                          |

where | is the cursor marker. How can I count, using vimscript, the total number of white spaces before the cursor until the first non space character (> in this case) ?

The aim is to delete all preceding whitespace before cursor, until non first space character (excluding it).

Source Link
simzz
  • 510
  • 3
  • 12
Loading