Comments (6)
Hey John, could you elaborate a bit more?
You mean a toggle where its sole responsibility would be to:
- take the last char at the end of the line
- Check if it is
,
or;
- Remove it.
- And then on hitting the toggle again it would re-insert it?
or just a toggle for toggling the plugin on and off?
from cosco.vim.
Your first understanding is what I meant. I asked this because it is needed for Matlab code. Adding ';' at the end is used to disable the print of the value of current line. Removing ';' at the end will enable it. It is very common for Matlab/Octave users. Would you please consider it? Thanks.
This is what I have in my .vimrc
. It can toggle the trailing ';'. But your plugin is cooler that can automatically inserts ',' or ';'
" If there isn't one, append a semicolon to the end of the current line and vice versa
function! s:ToggleTrailingSemiColon()
if getline('.') !~ ';$'
let original_cursor_position = getpos('.')
exec("s/$/;/")
call setpos('.', original_cursor_position)
else
" Useful for Octave/Matlab
let original_cursor_position = getpos('.')
exec("s/;$//")
call setpos('.', original_cursor_position)
endif
endfunction
" For programming languages using a semi colon at the end of statement.
autocmd FileType c,cpp,css,java,javascript,perl,php,jade,octave,tex nmap <silent> ;; :call <SID>ToggleTrailingSemiColon()<CR>
autocmd FileType c,cpp,css,java,javascript,perl,php,jade,octave,tex inoremap <silent> ;; <ESC>:call <SID>ToggleTrailingSemiColon()<CR>
from cosco.vim.
Right, interesting. Made me reminisce of my university days coding in matlab and octave :D
I can consider this, sure. Sounds like a nice thing to have. But I would ask more help of you, since I don't remember Matlab anymore:
- In matlab, can we use commas at the end of the lines at any moment? I mean, do I have to worry about inserting commas? If not, even better!!
😄 - Are there exceptions? For instance, in javascript, we would never want a line like this:
function myFunction() {;
, so Cosco will never try to insert either a comma or semicolon right after a{
. So, I need all of this rules... - What is the filetype for matlab and octave files? (type
:set ft
in vim to find out)
You could also have a look in the source code and issue a Pull Request for us -- you'll see it is not hard to understand. Have a look at the CSS filetype extension mechanism, we'd probably have to create one like this for the matlab/octave files.
This is definitely a nice thing to have, but first we need all these details above. And also, I need to go through the TODO list in the README first, making the plugin more stable and mature first, before diving into new features.
Thank you
from cosco.vim.
- Don't consider the trailing ',' at the moment for Matlab/Octave.
- There is exception in Matlab/Octave. But I have never used that.
- ft=matlab, ft=octave
Yes. You take your time.
from cosco.vim.
Thanks for the info.
Could elaborate more on the exception, although you've never used it? (Maybe some other users have/do).
Alright, don't forget you can always contribute trying to do it yourself and submitting a PR here
Thanks, John. Say hy to those .m
files for me
from cosco.vim.
Hey there. Sorry for the long delay. I had forgotten about this (actually, was also waiting on your reply for my last comment).
But I did it. Please test it and see if that's what you were wishing for.
It won't put a ;
in a function
declaration line, nor in a end
line, nor in a comment line (%
). Any other lines it will toggle the ;
. Sounds good to you? Any other possible handlings, feel free to suggest it or issue a PR: should be easy enough for anyone to implement it, just look the matlab.vim file.
Cheers
from cosco.vim.
Related Issues (18)
- When undoing, the cursor do not persist position HOT 3
- Experimental semicolon auto insertion breaks in non-editable buffers HOT 4
- Semicolons are added to comment lines HOT 3
- Semicolons added to methods if braces are opened on the next line HOT 2
- New "Undefined variable" error when invoking on Neovim HOT 5
- print "test"; # here's a comment (adds ; here) HOT 2
- colon support, in addition to comma or semicolon HOT 1
- Missplacing comma with semi-colon HOT 3
- Allow users to ignore semicolon insertion based on a regex pattern HOT 3
- Pass end symbol to the command as a fallback option
- g:auto_comma_or_semicolon needs "cosco" prefix for consistency HOT 1
- Doesn't recognize common comment blocks. HOT 8
- s:strip(string) not working on neovim
- Return to original position is 1 index behind if the action was triggered at the end of the line
- Automatically add needed semicolons HOT 4
- Make the action repeatable with `.` HOT 2
- Possible to use in Insert Mode? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cosco.vim.